在 MySQL 中查看授权
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/127679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
View grants in MySQL
提问by alanc10n
How do I view the grants (access rights) for a given user in MySQL?
如何在 MySQL 中查看给定用户的授权(访问权限)?
采纳答案by alanc10n
mysql> show grants for 'user'@'host'
回答by igelkott
An alternative method for recent versions of MySQL is:
MySQL 最新版本的另一种方法是:
select * from information_schema.user_privileges where grantee like "'user'%";
The possible advantage with this format is the increased flexibility to check "user's" grants from any host (assuming consistent user names) or to check for specific privileges with additional conditions (eg, privilege_type = 'delete').
这种格式的可能优点是增加了检查来自任何主机的“用户”授权(假设用户名一致)或检查具有附加条件的特定权限(例如,privilege_type = 'delete')的灵活性。
This version is probably better suited to use within a script while the "show grants" syntax is better for interactive sessions (more "human readable").
这个版本可能更适合在脚本中使用,而“show grants”语法更适合交互式会话(更“人类可读”)。
回答by Anita
You could try this:
你可以试试这个:
SELECT GRANTEE, PRIVILEGE_TYPE FROM information_schema.user_privileges;
SELECT User,Host,Db FROM mysql.db;
回答by Jon Topper
回答by Kevin ORourke
If you're already running a web server with PHP then phpMyAdminis a fairly friendly administrative tool.
如果您已经在使用 PHP 运行 Web 服务器,那么phpMyAdmin是一个相当友好的管理工具。