【Mysql】账号创建及授权管理

创建账户

本地: create user ‘caya’@’localhost’ identified by ‘123’;

远程: create user ‘caya2’@’192.168.1.2’ identified by ‘123’

远程网段: create user ‘caya2’@’192.168.1.%’ identified by ‘123’

远程全网: create user ‘caya2’@’ %’ identified by ‘123’

查看用户权限: select * from mysql.user\G;

 

授权表 root可见:

mysql.user                   查看所有用户权限

mysql.db                     查看所有库权限

mysql.tables_priv         查看所有表权限

mysql.columns_priv    

 

授权:

grant all ON *.* TO ‘caya’@’localhost’;     //允许所有授权

grant select ON *.* TO ‘caya’@’localhost’;  //允许select

grant select(name),update(age) ON db1.t1 TO ‘caya’@’localhost’;  //针对某一字段进行放权

 

回收权

REVOKE select ON *.* FROM ‘caya’@’localhost’;  //允许select

 

ON后内容:

to all user:             *.*

to databases:        db1.*

to tables:              db1.t1

to coloumes:         id,name

posted @ 2018-07-07 20:34  caya  阅读(69)  评论(0编辑  收藏  举报