MySQL权限管理

权限管理:

查询用户:
mysql8.0 [(none)]> select user,host ,authentication_string from mysql.user;
创建用户:
mysql8.0 [(none)]> create user test@'10.0.0.%' identified by '123';
删除用户
mysql8.0 [(none)]> drop user test@'10.0.0%';
修改用户密码
mysql8.0 [(none)]> alter user test@'10.0.0.%' identified by '123456';
授权
mysql8.0 [(none)]> grant all on *.* to test@'10.0.0.%' ;
授权规范
管理员 : ALL 
开发 : Create ,Create routine,Create temporary tables,Create view,Delete ,Event ,Execute,Insert ,References,Select,Show databases ,Show view ,Trigger,Update 
监控 : select , replication slave , client supper 
备份 : ALL 
主从 : replication slave 
业务 : insert , update , delete ,select
查看权限:
mysql8.0 [(none)]> show grants for @'10.0.0.%' ;
回收权限:
mysql8.0 [(none)]> revoke delete on *.* from test@'10.0.0.%';
调用非正常路径下的cnf文件:
mysqld_safe --defaults-file=/opt/oldguo.cnf &
忘记密码:
1、停数据库 
[root@db01 ~]# systemctl stop mysqld 
2、启动安全模式 
[root@db01 ~]# mysqld_safe --skip-grant- tables --skip-networking &
3、改密码 
mysql8.0 [(none)]> flush privileges; 
mysql8.0 [(none)]> alter user root@'localhost' identified by '123456'; 
4、重启数据库到正常模式
[root@db01 ~]# /etc/init.d/mysqld restart

你可能感兴趣的:(MySQL)