如何查看MYSQL数据库中所有用户及拥有权限

发布时间:2021-10-29 17:24:33 作者:小新
来源:亿速云 阅读:1658

小编给大家分享一下如何查看MYSQL数据库中所有用户及拥有权限,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

查看MYSQL数据库中所有用户

mysql> SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
+---------------------------------------+
| query                                 |
+---------------------------------------+
| User: 'cactiuser'@'%';                |
| User: 'common_user'@'%';              |
| User: 'dba'@'%';                      |
| User: 'root'@'%';                     |
| User: 'slave'@'%';                    |
| User: 'wtgame'@'%';                   |
| User: 'root'@'127.0.0.1';             |
| User: 'webman'@'127.0.0.1';           |
| User: 'root'@'192.168.166.200';       |
| User: 'cactiuser'@'192.168.166.202';  |
| User: 'root'@'192.168.166.202';       |
| User: ''@'localhost';                 |
| User: 'cacti'@'localhost';            |
| User: 'cactiuser'@'localhost';        |
| User: 'dba'@'localhost';              |
| User: 'extmail'@'localhost';          |
| User: 'javauser'@'localhost';         |
| User: 'root'@'localhost';             |
| User: 'webman'@'localhost';           |
| User: ''@'localhost.localdomain';     |
| User: 'root'@'localhost.localdomain'; |
+---------------------------------------+
21 rows in set (0.01 sec)

查看数据库中具体某个用户的权限
mysql> show grants for 'cactiuser'@'%';   
+-------------------------------------------------------------------------------------------------------------------+
| Grants for cactiuser@%                                                                                            |
+-------------------------------------------------------------------------------------------------------------------+
| GRANT PROCESS, SUPER ON *.* TO 'cactiuser'@'%' IDENTIFIED BY PASSWORD '*DAFF917B80E3314B1ABECBA9DF8785AFD342CE89' |
| GRANT ALL PRIVILEGES ON `cacti`.* TO 'cactiuser'@'%'                                                              |
+-------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> select * from mysql.user where user='cactiuser' \G  
*************************** 1. row ***************************
                 Host: %
                 User: cactiuser
             Password: *DAFF917B80E3314B1ABECBA9DF8785AFD342CE89
          Select_priv: N
          Insert_priv: N
          Update_priv: N
          Delete_priv: N
          Create_priv: N
            Drop_priv: N
          Reload_priv: N
        Shutdown_priv: N
         Process_priv: Y
            File_priv: N
           Grant_priv: N
      References_priv: N
           Index_priv: N
           Alter_priv: N
         Show_db_priv: N
           Super_priv: Y
Create_tmp_table_priv: N
     Lock_tables_priv: N
         Execute_priv: N
      Repl_slave_priv: N
     Repl_client_priv: N
     Create_view_priv: N
       Show_view_priv: N
  Create_routine_priv: N
   Alter_routine_priv: N
     Create_user_priv: N
           Event_priv: N
         Trigger_priv: N
             ssl_type:
           ssl_cipher:
          x509_issuer:
         x509_subject:
        max_questions: 0
          max_updates: 0
      max_connections: 0
 max_user_connections: 0

查看user表结构 需要具体的项可结合表结构来查询
mysql> desc mysql.user;
+-----------------------+-----------------------------------+------+-----+---------+-------+
| Field                 | Type                              | Null | Key | Default | Extra |
+-----------------------+-----------------------------------+------+-----+---------+-------+
| Host                  | char(60)                          | NO   | PRI |         |       |
| User                  | char(16)                          | NO   | PRI |         |       |
| Password              | char(41)                          | NO   |     |         |       |
| Select_priv           | enum('N','Y')                     | NO   |     | N       |       |
******************
******************
+-----------------------+-----------------------------------+------+-----+---------+-------+
39 rows in set (0.00 sec)

看完了这篇文章,相信你对“如何查看MYSQL数据库中所有用户及拥有权限”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

推荐阅读:
  1. MYSQL有哪些为用户指定权限
  2. 用户and权限

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

mysql

上一篇:怎么解决Nginx引起的图片显示过慢,文件下载不完全问题

下一篇:Mysql数据分组排名实现的示例分析

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》