skip to Main Content

How to Show grants for a user in MySQL

In MySQL, we can use the SHOW GRANTS command to display all grant information of a user. This would display privileges that we assigned to the user using the GRANT command.

The syntax of the SHOW GRANTS command is

SHOW GRANTS [ FOR username ]

Below is the example of how to use SHOW GRANTS command in MySQL :

SHOW GRANTS FOR 'user_sharedhow';

This would display all grant information of the user called ‘user_sharedhow’. In the this example, when you did not specific any host for the user, MySQL will assumes ‘%’ as the host. So it would be equivalent to the following command :

SHOW GRANTS FOR 'user_sharedhow'@'%';

Now let’s look at an other example of how to use command ‘SHOW GRANTS’ when we want to specific the host

SHOW GRANTS FOR 'user_sharedhow'@'localhost';


SHOW GRANTS FOR 'user_sharedhow'@'192.168.%.%';

This example would return the grant information for the user called ‘user_sharedhow’ on the host ‘localhost’ or ‘192.168.%.%’.

This Post Has 0 Comments

Leave a Reply

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

Back To Top