How do i show all users in MySQL?
1. Show databases all databases
2. Show tables display all data sheets
3, select Current_User (); Show Current user
4. Show All Users:
1. Log in to the database
First of all, you need to log in to the database using the following command, note that must be root user Oh ~
# # Mysql-u Root-p
2. Querying user Tables
In MySQL in fact there is a built-in database named MySQL , the database is stored in some MySQL data, such as users, permissions information, stored procedures, and so on, we can use the following simple query statement to display all users.
SELECT User, Host, Password from Mysql.user;
You will see a message like this:
+------------------+--------------+--------------+| User | host | password |+------------------+--------------+--------------+| root | 37as% #8123fs | | Debian-test-user | localhost | Hmbeqpjc5y | | johnsm | localhost | | | Brian | localhost | | | | root | 111.111.111.1| | | Guest |% | | | linuxprobe | 10.11.12.13 | RFSGY6AIVG |+------------------+--------------+--------------+7 rows in Set (0.01 sec)
If you want to increase or decrease the display of some columns, then you just need to edit this SQL statement, such as you only need to display the user's user name, then you can use the SELECT user from mysql.user; You can get all the users in this way, just try it.
Structure of the User data table:
3. Show all users (do not repeat)
Friends who are familiar with MySQL know the role of DISTINCT , that is, to remove duplicate data, so we can use the following command to display all of your MySQL users and ignore those who are only the host name of different users.
SELECT DISTINCT User from Mysql.user;
The output of this command is as shown below:
+------------------+| User | +------------------+| root | | debian-test-user | | JOHNSM | | Brian | | Guest | | linuxprobe
| +------------------+6 rows in Set (0.01 sec)
Show all users in MySQL