Thursday, 5 January 2017

How to get a list of user accounts using the command line in MySQL?



I'm using the MySQL command line utility and can navigate through a database. Now I need to see a list of user accounts. How can I do this?



I'm using MySQL version 5.4.1.


Answer



Use this query:



SELECT User FROM mysql.user;



Which will output a table like this:



+-------+
| User |
+-------+
| root |
+-------+
| user2 |
+-------+



As Matthew Scharley points out in the comments on this answer, you can group by the User column if you'd only like to see unique usernames.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...