Two Methods for viewing user permissions in MySQL

Source: Internet
Author: User

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.

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.