介绍两种查看MySQL用户权限的两种方法
1、 使用MySQL grants命令
1 | show grants for username@localhost; |
需要注意的是:
- username和ip的组合需要是在mysql.user表中存在的,具体可以通过
select * from mysql.user
命令查看 - ip地址如果是通配符格式需要加引号,例如:
show grants for root@'172.%'
;
2、 使用MySQL select命令
1 | select * from mysql.user where user='root' and host='localhost' \G; |
关于MySQL用户授权或撤权,请移步 MySQL用户管理