刷新权限

flush privileges;

在MySQL数据库下查询用户表是否修改成功

use mysql;
select host, user from user

MySQL8.0版本

# mysql -uroot -p
 MySQL [(none)]> create user db_user@'%' identified by 'db_pass'; #创建用户
 MySQL [(none)]> grant all privileges on db_name.* to db_user@'%' with grant option; #授权单个数据库权限
 MySQL [(none)]> grant all privileges on *.* to db_user@'%' with grant option; #授权数据库所有权限
 MySQL [(none)]> exit; #退出数据库控制台,特别注意有分号

其余MySQL版本

# mysql -uroot -p
 MySQL [(none)]> grant all privileges on db_name.* to db_user@'%' identified by 'db_pass'; #授权语句,

特别注意有分号

 MySQL [(none)]> flush privileges;
 MySQL [(none)]> exit; #退出数据库控制台,特别注意有分号

删除账号

delete from user where user='shao1' and host='localhost';

标签: mysql

添加新评论