30.4.1 通过SHOW GRANTS FOR语句查看用户权限
例如,查看binghe用户的权限。
mysql> SHOW GRANTS FOR binghe@localhost \G
*************************** 1. row ***************************
Grants for binghe@localhost: GRANT USAGE ON *.* TO 'binghe'@'localhost'
*************************** 2. row ***************************
Grants for binghe@localhost: GRANT SELECT, INSERT, UPDATE, DELETE ON `goods`.* TO 'binghe'@'localhost' WITH GRANT OPTION
2 rows in set (0.00 sec)
结果显示,binghe用户对goods数据库具有增、删、改、查权限,并具有GRANT权限,此时的host为localhost。
使用SHOW GRANTS FOR语句查看用户权限时,可以不指定host,如果没有指定host,则默认的host为“%”。
mysql> SHOW GRANTS FOR binghe \G
*************************** 1. row ***************************
Grants for binghe@%: GRANT PROCESS