How to check users, If you are not aware of how many users are on your server. The local user on the server will be able to login to the server but not on the MySQL Server. We can check and create MySQL users in Linux using the command line.
So you can check it via a command in MySQL. The local user and MySQL user are totally different from each other.
Check Out: Recover Root Password Of Mysql Server
How To Check Users On MySQL Server:
I can also use the select * from mysql.user; command to check the users in the server. If you need to login MySQL server with a user, So you will have to create it in MySQL server.
I have created a database with the name “testing“.
create database testing;
Created a user ‘ test’ with ‘password‘ using the below command.
CREATE USER 'test'@'192.168.185.129' IDENTIFIED BY "password";
Check Out: Mysql Error “Too Many Connections”
Now you can see how many users are present in your database server. I created one more user ‘ aryan’ with ‘passwordaryan’.
select user from mysql.user;
if you want to avoid repetitions of users when they connect from different origins.
select distinct user from mysql.user;
if you want to see the user with their IP address, run the below commands.
select user,host from mysql.user;
I can also check the user with their password by running the below command.
select user,host, passwpod from mysql.user;
You can also paste all the users in a text file using the below command.
mysql -e ‘ select user,host from mysql.user ‘ > userDatabase.txt
if you want to print the output and execute it on the MySQL server, you can use the below command.
mysql -u root -p -e ‘select user,host from mysql.user ‘ > userDatabase.txt
We can also get the listing of a field in mysql.user table using the below command.
You’re done. check users in mysql create