Monday, October 1, 2007

Show MySQL users from command line

Some times when you only have the MySQL command line client available and you need to “see” what users/grants are setup on the server here is a great little piece that gives you this information:

# mysql -e “SELECT User,Host,Password,Super_Priv,Grant_Priv,Repl_slave_priv,Repl_client_priv FROM mysql.user;”
+——+———-+———-+————+————+—————+—————-+
| User | Host | Password | Super_Priv | Grant_Priv | Repl_slave_priv | Repl_client_priv |
+——+———-+———-+————+————+—————+—————-+
| root | localhost | | Y | Y | Y | Y |
| root | hostname | | Y | Y | Y | Y |
| root | 127.0.0.1 | | Y | Y | Y | Y |
+——+———-+———-+————+————+—————+—————-+

No comments: