This article introduces two methods for viewing user permissions in MySQL.
Two Methods for ySQL to view user permission commands:
1. Use MySQL grants
Usage:
The Code is as follows: |
Copy code |
Mysql> show grants for username @ localhost; instance: Mysql> show grants for root @ localhost; + --------------------------------------------------------------------- + | Grants for root @ localhost | + --------------------------------------------------------------------- + | Grant all privileges on *. * TO 'root' @ 'localhost' with grant option | + --------------------------------------------------------------------- + 1 row in set (0.01 sec) |
2. query statements directly through mysql select:
The Code is as follows: |
Copy code |
Mysql> select * from mysql. user where user = 'test' and host = '2017. 0.0.1 'G; * *************************** 1. row *************************** Host: 127.0.0.1 User: test Password: * EB3C643405D7F53BD4BF7FBA98DCF5641E228833 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: N File_priv: N Grant_priv: N References_priv: N Index_priv: N Alter_priv: N Show_db_priv: N Super_priv: N 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 Create_tablespace_priv: N 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.00 sec) |
We can see Select_priv, Insert_priv, Update_priv... If N is set, the user has no permission.
In this case, you can use commands to grant permissions to users.
The Code is as follows: |
Copy code |
Grant all privileges on *. * to 'test' @ '2017. 0.0.1 'identified by 'passwd '; Flush privileges; in addition, show can see many things: Show databases; Show tables; Show create database dbname; // you can see some parameters used to create a database. Show create table tablename; // you can see the parameters used in table creation. |