MySQL 授权,回收权限,查看权限
show GRANTS for root@localhost;
flush privileges;
SHOW PROCESSLIST;
#全局授权,回收权限
GRANT ALL ON *.* TO 'testzzq'@'localhost';
REVOKE ALL ON *.* FROM 'testzzq'@'localhost';
flush privileges;
#数据库级别,授权,回收权限
GRANT ALL PRIVILEGES ON cs TO 'testzzq'@'localhost';
REVOKE ALL PRIVILEGES ON cs FROM 'testzzq'@'localhost';
flush privileges;
#数据库表级别,授权,回收权限
GRANT ALL PRIVILEGES ON cs.apply_reduction TO 'testzzq'@'localhost' WITH MAX_QUERIES_PER_HOUR 2;
GRANT SELECT(id,username),UPDATE(id,username) ON cs.user TO 'testzzq'@'localhost';
REVOKE SELECT,UPDATE ON cs.user from 'testzzq'@'localhost';
REVOKE ALL PRIVILEGES ON cs.apply_reduction FROM 'testzzq'@'localhost';
flush privileges;
授权公式:
GRANT
priv_type [(column_list)]
[, priv_type [(column_list)]] ...
ON [object_type] priv_level
TO user [auth_option] [, user [auth_option]] ...
[REQUIRE {NONE | tls_option [[AND] tls_option] ...}]
[WITH {GRANT OPTION | resource_option} ...]
resource_option: {
| MAX_QUERIES_PER_HOUR count
| MAX_UPDATES_PER_HOUR count
| MAX_CONNECTIONS_PER_HOUR count
| MAX_USER_CONNECTIONS count
}
The number of queries an account can issue per hour
一个账号每小时可以发起查询操作的个数
The number of updates an account can issue per hour
一个账号每小时可以发起更新操作的个数
The number of times an account can connect to the server per hour
一个账号每小时可以连接服务器的次数
The number of simultaneous connections to the server by an account
一个账号同时可以连接服务器的个数,
#查看权限
show GRANTS for 'testzzq'@'localhost'