首頁  >  文章  >  資料庫  >  兩種MySQL查詢使用者權限的方法

兩種MySQL查詢使用者權限的方法

藏色散人
藏色散人轉載
2020-03-05 09:53:253189瀏覽

介紹兩種檢視MySQL使用者權限的兩種方法

1、 使用MySQL grants指令

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

要注意的是:

● username和ip的組合需要是在mysql.user表中存在的,具體可以透過select * from mysql.user 指令查看

● ip位址如果是通配符格式需要加引號,例如:show grants for root@'172.%';

推薦:《mysql教學

2、 使用MySQL select指令

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)

更多程式相關內容,請關注php中文網程式設計入門欄位!

以上是兩種MySQL查詢使用者權限的方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:segmentfault.com。如有侵權,請聯絡admin@php.cn刪除