How to view users in MySQL using Linux

is one of the most popular database administrators in the world. It has many features that make it reliable, robust and efficient. However, as with any other program, its maximum reliability is achieved if we use it correctly. Knowing this, let’s move on to talk a bit about viewing users in MySQL.

An easy and reliable way to increase MySQL security is to create users with limited permissions in the database. In this tutorial, you will learn how to view such users in MySQL, so that you can efficiently manage databases in a Linux terminal environment on your .

Why create users in MySQL?

When installing MySQL on Linux, the first user to be created is the root user (or root user), who is the MySQL administrator. The root user has permission to do everything in the MySQL database, so it is not convenient for other people to access your databases using this account.

On the other hand, hackers always try to log in as root user to steal hosted information. Or worse, destroy the service and associated data.

With this in mind, ideally the system administrator creates users with specific permissions to the databases and, in turn, to the tables. This way, if that user’s security is compromised, the impact is minimal and/or manageable.

How to view users in MySQL on Linux

Next you will learn the easiest method that exists to display users in MySQL:

1. Login with SSH

First, you must access the server using SSH. We have a detailing the process to do it!

See also  MariaDB vs MySQL: Key Differences, Pros and Cons, and More

ssh your-user@your-server

2. Make sure you have root privileges

When you have access to your server, you will have to enter the MySQL console. To do so, you will need root privileges. Enter this on the command line:

sudo mysql -u root -p

3. Type your MySQL root password

Next, you will need to type your MySQL root password. It must be different from the system root password.

Once you are in the MySQL console as the root user, you will be able to execute sentences and commands.

4. Show MySQL users

Now you will be able to list all the users created in MySQL through the following MySQL command:

mysql> SELECT user FROM mysql.user;

As a result, you will see all the users that have been created in MySQL.

5. Add a host column (optional)

There may be duplicate users. This is because MySQL filters access to a server based on the IP address it comes from. So you can also add a host column.

mysql> SELECT user,host FROM mysql.user;

In this way, you will be able to see the users from and from which host or IP address they have permission to access.

conclusion

Managing a database server is not always an easy task. Therefore, you must be careful about creating and managing user permissions. Now you know how to view MySQL users linked to a database. And, if you still have doubts, you can consult the one on permissions and user creation.

Deyi is a digital marketing enthusiast, with a background in web design, content creation, copywriting, and SEO. She is part of ‘s SEO & Localization team. In her free time, she likes to develop projects, read a book or watch a good movie.

Loading Facebook Comments ...
Loading Disqus Comments ...