SELECT * FROM mysql.user;
要执行该语句,必须拥有对 user 表的查询权限。SHOW GRANTS FOR 'username'@'hostname';
其中,username 表示用户名,hostname 表示主机名或主机 IP。mysql> CREATE USER 'testuser1'@'localhost'; Query OK, 0 rows affected (0.00 sec) mysql> SHOW GRANTS FOR 'testuser1'@'localhost'; +-----------------------------------------------+ | Grants for testuser1@localhost | +-----------------------------------------------+ | GRANT USAGE ON *.* TO 'testuser1'@'localhost' | +-----------------------------------------------+ 1 row in set (0.00 sec)其中,
USAGE ON *.*
表示该用户对任何数据库和任何表都没有权限。
mysql> SHOW GRANTS FOR 'root'@'localhost'; +---------------------------------------------------------------------+ | Grants for root@localhost | +---------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION | | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION | +---------------------------------------------------------------------+ 2 rows in set (0.00 sec)
本文链接:http://task.lmcjl.com/news/18025.html