grant 权限 on 数据库.* to 用户名@登录主机> grant select on testdb.* to common_user@'%''; 授权指定用户对指定数据查询权限
grant select on testdb.* to user1@'localhost',user2@'localhost'; 授权多个用户对指定数据查询权限
grant create,delete,insert,update on testdb.* to developer@'192.168.0.%'; 授权指定用户对指定数据创建,删除,增加,更新权限
grant select (name,age) on dbname.tables to hunk@'localhost'; 授权指定用户对指定表中的某些字段查询权限
grant ALL on testdb.* to developer@'192.168.0.%' whit grant option; 授权指定用户对指定数据创建,删除,增加,更新权限,并且授权用户可以为其他用户授权(谨慎)
grant usage on *.* to 'hunk'@'192.168.0.1' require ssl; 强制用户使用ssl连接
grant usage on *.* to 'hunk'@'192.168.0.1' require none; 强制用户使用ssl连接
EVOKE ALL ON *.* FROM 'username'@'localhost'; 回收指定用户全部权限
EVOKE update ON *.* FROM 'username'@'localhost'; 回收指定用户update权限
Show grants; 查看当前用户(自己)权限
show grants for dba@localhost 查看其他用户权限
设置用户权限
grant select on legacy.* to mary@'localhost'>
grant select,insert,update,delete on legacy.* to legacy@'localhost'>
grant select on legacy.* to report@'localhost"> MySQL grant 权限,分别可以作用在多个层次上。
1. grant 作用在整个 MySQL 服务器
2. grant 作用在单个数据库
3. grant 作用在单个数据表
4. grant 作用在表中的列
5. grant 作用在存储过程、函数