0%

005-mysql-查看MYSQL数据库中所有用户及拥有权限

摘要:005-mysql-查看MYSQL数据库中所有用户及拥有权限

查看MYSQL数据库中所有用户

1
2
3
4
5
6
7
8
9
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
-- +------------------------------------+
-- | query |
-- +------------------------------------+
-- | User: 'root'@'%'; |
-- | User: 'mysql.session'@'localhost'; |
-- | User: 'mysql.sys'@'localhost'; |
-- | User: 'root'@'localhost'; |
-- +------------------------------------+

查看数据库中具体某个用户的权限

1
2
3
4
5
6
7
show grants for 'root'@'%'; 
-- +-------------------------------------------------------------+
-- | Grants for root@% |
-- +-------------------------------------------------------------+
-- | GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION |
-- +-------------------------------------------------------------+
-- 1 row in set (0.00 sec)
1
2
3
4
5
6
7
8
select * from mysql.user where user='root' \G   
-- *************************** 1. row ***************************
-- Host: localhost
-- User: root
-- Select_priv: Y
-- Insert_priv: Y
-- Update_pr
-- ……

查看user表结构 需要具体的项可结合表结构来查询

1
desc mysql.user;
一分也是爱,两分情更浓【还没有人赞赏,支持一下呗】