【mysql】用户管理

2020-04-08  本文已影响0人  马蹄哒

环境: mysql8.0.19

添加用户

create user 'testuser'@'%' identified by '‘密码';
create user 'testuser'@'localhost' identified by '‘密码';
create user 'testuser'@'IP地址' identified by '‘密码';

修改密码

alter user 'testuser'@'localhost' identified by '新密码';

添加用户权限

grant all privileges on *.* to 'testuser'@'localhost' with grant option;

with gran option - 表示该用户可给其它用户赋予权限,但不可能超过该用户已有的权限

grant all privileges on *.* to 'testuser'@'localhost';
grant all privileges on 数据库名.* to 'testuser'@'localhost';
grant all privileges on 数据库名.表名 to 'testuser'@'localhost';

注:all privileges 可以替换成具体的权限:select,update,insert,delete,drop等

刷新权限

flush privileges;

移除用户权限

revoke all privileges on *.* from 'testuser'@'localhost';

查看用户权限

show grants for 'testuser'@'localhost';

删除用户

drop user 'testuser'@'localhost';
上一篇 下一篇

猜你喜欢

热点阅读