show user permissions in mysql

How to Show User Permissions in MySQL

MySQL allows you to define specific permissions for each database user on your system. But sometimes you may need to find out permissions of a specific user in MySQL. Database administrators often have this requirement to ensure that the users only have appropriate permissions. In this article, we will learn how to show user permissions in MySQL.


How to Show User Permissions in MySQL

It is very easy to see user permissions for specific user using show grants statement.

show grants for [username]

In the above command, you need to mention the username after show grants command. Here is an example.

mysql> show grants for root@localhost;
mysql> show grants for test_user@54.43.32.21;

Please note, in the above commands, you need to mention the username (e.g. root) as well as the host (e.g. localhost) from which the user has access to your system.

If you want to view the permissions assigned to the current user that you are using to connect to MySQL server, you can use any of the following commands.

SHOW GRANTS;
SHOW GRANTS FOR CURRENT_USER;
SHOW GRANTS FOR CURRENT_USER();

SHOW GRANTS statement displays privileges granted explicitly to the named account. Even though the account might have other privileges, SHOW GRANTS statement will not show them.

In this show article, we have learnt how to view permissions for MySQL users.

Also read:

How to Force Git Pull to Overwrite Local Changes
How to Check SSL Certificate in Linux
How to Enable SSL for MySQL in Windows
How to Append One File to Another in Linux
How to Rename Git Tag

Leave a Reply

Your email address will not be published. Required fields are marked *