Gice

Technology and General Blog

If you have at any time tried to get a checklist of people obtainable in your MySQL server, you will observe there is no native command to do this. For case in point, to get a listing of databases, you can simply question Present DATABASES. Having said that, this is not the scenario for users.

This information will display you how you can see the customers obtainable in your MySQL utilizing simple and speedy instructions.

MySQL Dump All Customers

To get the facts about the users in the server, we query the users’ table accessible in the MYSQL databases for certain data.

Make certain that the server is up and functioning. Up coming, log in to the server making use of the root consumer as revealed in the command:

For example, retrieve the User and Host rows in the MySQL.buyers desk working with the Pick out assertion as shown under:

The previously mentioned question will exhibit the username and the host of all the buyers on the server. Below is an case in point output:

mysql> Find User, Host FROM mysql.consumer
+——————+————–+
| User             | Host         |
+——————+————–+
| LT.Spock         | 10.10..14   |
| Uhura            | 172.23.58.23 |
| captain.kirk     | localhost    |
| mysql.infoschema | localhost    |
| mysql.session    | localhost    |
| mysql.sys        | localhost    |
| root             | localhost    |
+——————+————–+
7 rows in set (.00 sec)

Be aware: In the earlier mentioned question, we limit the rows to Consumer and Host but the table consists of extra rows this kind of as account_locked, Consumer_attributes, Delete_Priv, and so forth.

To look at all the rows about the table, use the DESC question as proven beneath:

The output is as demonstrated underneath:

Show Present Person

To watch the existing user logged in, you can use the existing_person() function as revealed beneath:

An case in point output is down below:

Demonstrate Logged in End users

Utilizing the data_schema database and the course of action checklist table, we can get facts about the logged-in users. The procedure_list table is made up of the listing of operations at this time currently being executed by numerous threads in the server.

Supply: https://dev.mysql.com/doc/refman/8./en/information-schema-processlist-table.html

To watch the logged-in buyers, use the Query as proven beneath:

Pick id, person, host, db, command, condition FROM info_schema.processlist

This will screen information this kind of as the id, consumer, etc., of the logged-in buyers and the at the moment jogging command.

Here is an example output:

Conclusion

In this tutorial, we discussed how to see end users and their corresponding info by querying the MySQL.users table.

Thank you for looking through.

Leave a Reply

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