mysql 权限管理 grant 命令

 

 

只有root账号可以授权,其他账号不能用grant 授权

mysql> select user();
+----------------+
| user()         |
+----------------+
| mike@localhost |
+----------------+
1 row in set (0.00 sec)

mysql> 
mysql> 
mysql> grant all on *.* to 'mike'@'localhost';
ERROR 1045 (28000): Access denied for user 'mike'@'localhost' (using password: YES)

 

 

#授权:对文件夹,对文件,对文件某一字段的权限
查看帮助:help grant
常用权限有:select,update,alter,delete
all可以代表除了grant之外的所有权限

 

针对select语句 授权

grant select 

 

所有权限

grant all

 

对所有库、所有表授权

 

我为mike @ localhost这个账号 授予了所有库、所有表的所有权限

 

grant all on *.* to 'mike'@'localhost' ;

 

 

 

 如果没有mike账号,用这条命令做到创建mike账号 设置一个密码123 并且授予 所有库,所有表的所有权限

创建账号并授权

 

grant all on *.* to 'mike'@'localhost' identified by '123';

 

 

 

 

刷新

 

flush privileges;

 

 

 

 

% 表示对所有ip

对mike这个账号所有ip 授予所有库,所有表的所有权限

grant all on *.* to 'mike'@'%' identified by '123';

 

posted @ 2019-03-13 16:54  minger_lcm  阅读(355)  评论(0)    收藏  举报