Got it

The Series of MySQL -3- MySQL User Management - EP 03_03

Latest reply: Mar 2, 2022 04:49:20 673 21 15 0 0

The Series of MySQL -2- MySQL User Management - EP 03_03


HI Hi, Greetings!  i_f47.gif 

Happy January i_f25.gif


Hi Everyone,


Today, I would like to share with you an article about the third episode of Series of MySQL (MySQL User Management), and the content is given below.


a. MySQL Create User

b. MySQL Drop User

c. MySQL Show Users

d. MySQL User Password Change 

MySQL Show User

You may need to administer a database in MySQL on occasion. In such a situation, we'll need access to a database that has a list of all user accounts. Most of the time, we presume that the database server has a SHOW USERS command, similar to SHOW DATABASES, SHOW TABLES, and so on, for presenting a list of all users. Unfortunately, there is no SHOW USERS command in the MySQL database to display a list of all users on the MySQL server. To see a list of all users on the database server, run the following query:


mysql> Select user from mysql.user;  

Following the successful execution of the above command, we will retrieve user data from the MySQL database server's user table.

Let's take a look at how we can use this query. To begin, we must use the mysql client tool to connect to the MySQL server and log in as an administrator to the server database. Run the following command:

> mysql -u root -p  

Enter password: *********  

mysql> use mysql;  

Database changed  

mysql> SELECT user FROM user;  

We'll see the five users in our local database in the output that follows::


Execute the following command to see more information about the user table:

mysql> DESC user;  

It will print the following result, which contains a list of all the columns available in the mysql.user database:


Execute the following query to acquire the desired information, such as hostname, password expiration status, and account locking:

mysql> SELECT user, host, account_locked, password_expired FROM user;  

It will produce the following output after a successful execution:


Display current user

The user() or current user() functions can be used to acquire information about the current user, as seen below:

mysql> Select user();  


mysql> Select current_user();  

We will obtain the following output after running the aforementioned command:


Display current logged user

Using the following query on the MySQL server, we can determine who is currently logged in to the database server:

mysql> SELECT user, host, db, command FROM information_schema.processes;  

The output of the command above is as follows:


We can see from this output that there are presently four users logged into the database, one of them is running a query while the others are in the Sleep states.

You are welcome to like and leave feedback in the comment area. 


EP 03_01:

The Series of MySQL -3- MySQL User Management - EP 03_01

EP 03_02:

The Series of MySQL -3- MySQL User Management - EP 03_02

EP 03_04:

The Series of MySQL -2- MySQL User Management - EP 03_04




M M Zaheer Hussain

Stay Safe!


The post is synchronized to: Author groupzaheernew's Author Collection

  • x
  • convention:

MVE Author Created Jan 23, 2022 19:24:43

  • x
  • convention:

BWGARM Created Jan 26, 2022 15:21:10 (0) (0)
Very clear explanation.  
andersoncf1 Created Jan 30, 2022 18:03:30 (0) (0)
MVE Created Jan 24, 2022 01:23:19

View more
  • x
  • convention:

zaheernew Created Jan 25, 2022 12:45:16 (0) (0)
Great support from you  
Created Jan 26, 2022 07:37:32

well explained
View more
  • x
  • convention:

Created Jan 26, 2022 16:19:20

Thanks for the share
View more
  • x
  • convention:

MVE Author Created Jan 26, 2022 17:16:05

View more
  • x
  • convention:

zaheernew Created Jan 26, 2022 17:22:47 (0) (0)
Fantastic my friend  
Created Jan 26, 2022 19:56:52

Informative post. Keep up the good work
View more
  • x
  • convention:

Created Jan 27, 2022 16:37:40

Well explained. Thank you

View more
  • x
  • convention:

Created Jan 27, 2022 16:49:13

Thank you for your sharing
View more
  • x
  • convention:

Moderator Created Jan 29, 2022 15:34:55

Thank for sharing
View more
  • x
  • convention:

Back to list


You need to log in to comment to the post Login | Register

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits


Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Please bind your phone number to obtain invitation bonus.
Information Protection Guide
Thanks for using Huawei Enterprise Support Community! We will help you learn how we collect, use, store and share your personal information and the rights you have in accordance with Privacy Policy and User Agreement.