MySQL View user permissions in two ways

Source: Internet
Author: User

Ysql two ways to view user permission commands:

A. Use MySQL grants

How to use:

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 in *.* to ' root ' @ ' localhost ' with GRANT OPTION |
+---------------------------------------------------------------------+
1 row in Set (0.01 sec)

Two. Directly through the MySQL select query statement:

The code is as follows Copy Code
Mysql> SELECT * from Mysql.user where user= ' test ' and host= ' 127.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)

Can see Select_priv,insert_priv,update_priv ... As n indicates no permissions, the user right is at a glance.

You can then use the command to add permissions to the user

The code is as follows Copy Code

Grant all privileges "*.* to ' Test" @ ' 127.0.0.1 ' identified by ' passwd ';
Flush Privileges In addition: show can see a lot of things:

show databases;
Show tables;
Show CREATE Database dbname; This will see some of the parameters used to create the database.
Show CREATE TABLE tablename; You can see some of the parameters that are used to create the table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.