MySQL用户权限查看

来源: 2024-07-06 14:01:47 播报

格式:

show grants;

示例:

mysql> show grants;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0.00 sec)

查看某个用户的权限:

mysql> show grants for 'pig';
+-----------------------------------------------------+
| Grants for pig@%                                    |
+-----------------------------------------------------+
| GRANT USAGE ON *.* TO 'pig'@'%'                     |
| GRANT SELECT, INSERT ON `mysql`.`user` TO 'pig'@'%' |
+-----------------------------------------------------+
2 rows in set (0.00 sec)