See Mysql Users: How to list mysql users and manage access

ABOUT MySQL

MySQL is an open source relational database management system. MySQL is a component of the LAMP web application software stack, which is an acronym for Linux, Apache, MySQL, PHP. A web application using MySQL database have to authenticate via a mysql user and password who has sufficient privileges on that particular database. So MySQL users play a key role in web application hosting.

In this article, we will show you how you can list all your existing MySQL users and how you can add new users via both cPanel and Command line interfaces.

How to list MySQL users via cPanel GUI?

Log in to your cPanel account and then on Databases section select MySQL Databases.

Scroll down to bottom, here you will see Current Users. All MySQL users currently existing on our system will be listed here. One example of user listing is shown below:

In our system, we added only one user at present.

How to list MySQL users via Command Line Interface?

Login to mysql using the following command:

Use appropriate username in place of ‘user’

It will be prompted to enter the password for the user.

Now you entered MySQL CLI.

All details about existing MySQL users are stored in a table named ‘mysql.user’. The ‘mysql.user’ table contains information about users that have permission to access the MySQL server and their global privileges.

To list all existing MySQL users on the server use the query given below:

The above command trims off “User” column and lists only usernames.

If you want to list of MySQL user information, including user permission information and all users data. You could try below query.

Now we have seen how to list MySQL users from both cPanel and Command Line.

How to add MySQL users via cPanel?

Log in to your cPanel account and then on Databases section select MySQL Databases.

Scroll down, you will see Add New User.

Enter the name of the user you want to add and create a password for this user.

Click on ‘Create User’ button.

You will get a confirmation dialogue on the next screen.

You can see the newly created user on ‘Current Users’ section:

 

How to add MySQL users via Command Line Interface?

Login to MySQL interface using the following command:

To add a new MySQL user use the following query:

Replace ‘user_name’ and ‘password’ entries with actual username and password.

An example is shown below:

Now to list the created user use the following command:

That’s all!

Leave a Reply

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