Preamble
In MySQL, you can use the SHOW GRANTS statement to display all grant information for the user. This will display the privileges that have been assigned to the user with the GRANT command.
Syntax of SHOW GRANTS statement in MySQL
SHOW GRANTS [ FOR username ]
Statement parameters and arguments
- user_name – the name of the database account for which grant-information shall be displayed.
Note:
- To view user privileges (i.e. not CURRENT_USER), you must have the SELECT privilege in your MySQL database.
An example of using SHOW GRANTS command in MySQL to display grant information for a user
SHOW GRANTS FOR 'trizar';
In this example, you will see all grant information for a user called ‘trizar’. Each line returned by the SHOW GRANTS command is a GRANT operator that can be used to recreate privileges. This is a great way to capture the privileges that you want to save later.
In this first example, when you don’t specify a host for a username, MySQL accepts % as the host, so the above example is equivalent to the next SHOW GRANTS command.
For example:
SHOW GRANTS FOR 'trizar@'%';
Now let’s look at an example of using the SHOW GRANTS command when we want to specify a host.
For example:
SHOW GRANTS FOR 'trizar'@'localhost';
This example SHOW GRANTS will return grant information to a user named ‘trizar’ on the host ‘localhost’.
MySQL; Create, Delete User Accounts and Grant Privileges (create/drop user, grant, show grants)
About Enteros
Enteros offers a patented database performance management SaaS platform. It proactively identifies root causes of complex business-impacting database scalability and performance issues across a growing number of clouds, RDBMS, NoSQL, and machine learning database platforms.
The views expressed on this blog are those of the author and do not necessarily reflect the opinions of Enteros Inc. This blog may contain links to the content of third-party sites. By providing such links, Enteros Inc. does not adopt, guarantee, approve, or endorse the information, views, or products available on such sites.
Are you interested in writing for Enteros’ Blog? Please send us a pitch!
RELATED POSTS
Maximizing ROI with Enteros: Cloud FinOps Strategies for Reserved Instances and Database Optimization
- 28 November 2024
- Database Performance Management
In the fast-evolving world of finance, where banking and insurance sectors rely on massive data streams for real-time decisions, efficient anomaly man…
Revolutionizing Healthcare with RevOps: Integrating Cloud FinOps, AIOps, and Observability Platforms for Operational Excellence
In the fast-evolving world of finance, where banking and insurance sectors rely on massive data streams for real-time decisions, efficient anomaly man…
Enhancing Accountability and Cost Estimation in the Financial Sector with Enteros
- 27 November 2024
- Database Performance Management
In the fast-evolving world of finance, where banking and insurance sectors rely on massive data streams for real-time decisions, efficient anomaly man…
Optimizing E-commerce Operations with Enteros: Leveraging Enterprise Agreements and AWS Cloud Resources for Maximum Efficiency
In the fast-evolving world of finance, where banking and insurance sectors rely on massive data streams for real-time decisions, efficient anomaly man…