曲径通幽论坛

标题: 使用 SHOW GRANTS 查看用户权限 [打印本页]

作者: beyes    时间: 2012-4-27 16:26
标题: 使用 SHOW GRANTS 查看用户权限
SHOW GRANTS 语句可以查看用户已获得的授权,如果查看当前用户自身权限,可直接运行 SHOW GRANTS,如:
mysql> show grants;
[attach]354[/attach]

如果要查看其它用户的权限,可以先查看 mysql.user 表中都有哪些用户:
mysql> select user from mysql.user;
[attach]355[/attach]
现在查看 Anono 这个用户的权限:
mysql> show grants for 'Anono'@'localhost';
[attach]357[/attach]
注意,查看其它用户的权限时,一般需要指定 host 部分,不然有可能出错,如:
mysql> show grants for Anono;
ERROR 1141 (42000): There is no such grant defined for user 'Anono' on host '%'
这里,默认查看的是 'Anono'@'%' ,而表里只有 'Anono‘@’localhost' 。




欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) Powered by Discuz! X3.2