安全用户角色权限

负载均衡策略:权重、轮询、iphash、最少连接、urlhash

http{

    Upstream groupname{

        Server  ip/域名:端口   策略;

       ……

    }

    Server{

       Listen 80;

       Servername  ip/域名;

       Root    /opt/html;

       Location   / {

             Proxy_pass   http://groupname;

       }

   }

}

一、glibc安装

1、装包解压

[root@zhu ~]# yum list installed | grep libaio

libaio.x86_64                         0.3.109-13.el7                   @anaconda

[root@zhu ~]#

wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.33-linux-glibc2.12-x86_64.tar

[root@zhu ~]# tar -xvf mysql-8.0.33-linux-glibc2.12-x86_64.tar

mysql-test-8.0.33-linux-glibc2.12-x86_64.tar.xz

mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz

mysql-router-8.0.33-linux-glibc2.12-x86_64.tar.xz

[root@zhu ~]# tar -xvf mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz

[root@zhu ~]# ls mysql-8.0.33-linux-glibc2.12-x86_64

bin  docs  include  lib  LICENSE  man  README  share  support-files

[root@localhost ~]# mv mysql-8.0.33-linuxglibc2.12-x86_64/ /mysql8

[root@localhost ~]# ls /mysql8/

bin  docs  include  lib  LICENSE  man  README  share  support-files

2、指定不可登录

[root@zhu ~]# useradd -r -s /sbin/nologin mysql

[root@zhu ~]# id mysql

uid=997(mysql) gid=994(mysql) 组=994(mysql)

[root@zhu ~]#

3、创建文件

[root@localhost mysql8]# chown mysql:mysql mysqlfiles/

[root@localhost mysql8]# chmod 750 mysql-files/

4、初始数据库

[root@zhu mysql-8.0.33-linux-glibc2.12-x86_64]# ./bin/mysqld --initialize  --user=mysql -basedir=/mysql-8.0.33-linux-glibc2.12-x86_64/

[root@localhost mysql8]# cp supportfiles/mysql.server /etc/init.d/mysql8

[root@localhost mysql8]# ls /etc/init.d/mysql8

/etc/init.d/mysql8

[root@localhost mysql8]# ls /etc/init.d/

functions mysql8 mysql8ls netconsole network README

[root@localhost mysql8]#

二、密码安全策略

1、查看密码策略

2、修改策略

mysql> set global validate_password.length=0;

mysql> set global validate_password.policy=LOW;

三、⽤户

1、创建⽤户

mysql> create user 'efg'@'%' identified by 'efg';

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

mysql> create user 'efgh'@'%' identified by 'efgh';

Query OK, 0 rows affected (0.01 sec)

2、删除用户

mysql> drop user 'zhangmin';

Query OK, 0 rows affected (0.02 sec)

3、修改用户

mysql> alter user 'zhangmin' identified by 'abc123';

Query OK, 0 rows affected (0.01 sec)

四、创建角色

mysql> create role 'a';

Query OK, 0 rows affected (0.00 sec)

五、权限

1、刷新权限

mysql> create role 'a';

Query OK, 0 rows affected (0.00 sec)

2、为root账户刷新权限

mysql> grant system_user on *.* to "root";

3、修改权限

mysql> show grants for "efgh";

4、删除权限

mysql> revoke all on *.* from "efgh";

Query OK, 0 rows affected (0.00 sec)

练习:

1.添加aaa账户,设置密码aaaa

drop user aaa;

create user 'aaa'@'%' identified by 'aaaa';

2.使用aaa账户访问mysql服务

mysql -h127.0.0.1 -P3306 -uaaa -paaaa

3.查看test数据库发现么有权限

show databases;

4.退出并使用root账户登录

quit|exit

mysql -h127.0.0.1 -P3306 -uroot -proot0000

5.为aaa账户添加查看test.user表的权限

grant select on test.user to 'aaa';

6.退出root,使用aaa账户登录

quit|exit

mysql -h127.0.0.1 -P3306 -uaaa -paaaa

7.查看数据库,查看表,查看表内容 能够正常查看

show databases;

user test;

show tables;

select * from user;

8.输入数据,没有权限

insert into user values(5,"ermazi","ermazi");####

9.退出aaa使用root登录

quit|exit

mysql -h127.0.0.1 -P3306 -uroot -proot0000

10.为aaa添加insert权限

grant insert on test.user to 'aaa';

11.退出root使用aaa登录

exit|quit

mysql -h127.0.0.1 -P3306 -uaaa -paaaa

12.向user表添加一行新的数据

insert into test.user values(6,"zhangsanfeng","zhangsanfen");

13.修改user中一行的数据的password(密码)为111,没有update权限

update test.user set password='zsf' where username-'zhangsanfeng';

  • 25
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值