Home > Database > Mysql Tutorial > Two ways to query user permissions in MySQL

Two ways to query user permissions in MySQL

藏色散人
Release: 2020-03-05 09:53:25
forward
3350 people have browsed it

Introducing two methods to view MySQL user permissions

1. Use the MySQL grants command

mysql> show grants for username@localhost;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
Copy after login

It should be noted that:

● The combination of username and ip needs to exist in the mysql.user table. You can view it through the select * from mysql.user command.

● If the ip address is in wildcard format, it needs to be quoted, for example: show grants for root@'172.%';

Recommended: "mysql tutorial"

2. Use the MySQL select command

mysql> select * from mysql.user where user='root' and host='localhost' \G;
*************************** 1. row ***************************
                  Host: localhost
                  User: root
              Password: **********************
           Select_priv: Y
           Insert_priv: Y
           Update_priv: Y
           Delete_priv: Y
           Create_priv: Y
             Drop_priv: Y
           Reload_priv: Y
         Shutdown_priv: Y
          Process_priv: Y
             File_priv: Y
            Grant_priv: Y
       References_priv: Y
            Index_priv: Y
            Alter_priv: Y
          Show_db_priv: Y
            Super_priv: Y
 Create_tmp_table_priv: Y
      Lock_tables_priv: Y
          Execute_priv: Y
       Repl_slave_priv: Y
      Repl_client_priv: Y
      Create_view_priv: Y
        Show_view_priv: Y
   Create_routine_priv: Y
    Alter_routine_priv: Y
      Create_user_priv: Y
            Event_priv: Y
          Trigger_priv: Y
Create_tablespace_priv: Y
              ssl_type:
            ssl_cipher:
           x509_issuer:
          x509_subject:
         max_questions: 0
           max_updates: 0
       max_connections: 0
  max_user_connections: 0
                plugin: mysql_native_password
 authentication_string:
      password_expired: N
1 row in set (0.01 sec)
Copy after login

For more programming related content, please pay attention to the Introduction to Programming column on the php Chinese website!

The above is the detailed content of Two ways to query user permissions in MySQL. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template