数据库
首页 > 数据库> > mysql创建新用户并授权限

mysql创建新用户并授权限

作者:互联网

1. 创建用户

CREATE USER 'user01'@'localhost' IDENTIFIED BY '123456';

2.赋予用户只读权限

GRANT SELECT, SHOW VIEW ON `database`.* TO 'user01'@'localhost' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;

3.赋予用户只能查询某一张表或视图的权限

GRANT SELECT, SHOW VIEW ON database.tableName TO 'user01'@'localhost';

4.赋予用户所有权限

GRANT ALL ON *.* TO user01@'%' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;

5.查询用户拥有的权限

SHOW GRANTS FOR use01@localhost

 

标签:SHOW,创建,用户,IDENTIFIED,localhost,mysql,授权,123456,user01
来源: https://www.cnblogs.com/funian/p/15555390.html