How to see/get a list of MySQL/MariaDB users accounts

How to see/get a list of MySQL/MariaDB users accounts

To see a list of MySQL/MariaDB user accounts, you can use the mysql command-line client and execute the following SQL query:

ref‮ot re‬:lautturi.com
SELECT User, Host FROM mysql.user;

This will show the list of MySQL/MariaDB user accounts and the hostnames they are allowed to connect from.

For example, the output might look something like this:

+------------------+-----------+
| User             | Host      |
+------------------+-----------+
| root             | %         |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| testuser         | %         |
+------------------+-----------+

This indicates that there are four user accounts: root, mysql.session, mysql.sys, and testuser. The % symbol in the Host column indicates that these users are allowed to connect from any host.

You can also use the mysql_users script to see a list of MySQL/MariaDB user accounts. To use the mysql_users script, you need to install the mysql-client-core-5.7 package on your system.

To install the mysql-client-core-5.7 package on Ubuntu or Debian, run the following command:

sudo apt-get install mysql-client-core-5.7

To install the package on CentOS or Fedora, run the following command:

sudo yum install mysql-client-core-5.7

After installing the package, you can use the mysql_users script to see a list of MySQL/MariaDB user accounts:

mysql_users

This will show the list of MySQL/MariaDB user accounts and their privileges.

Created Time:2017-10-29 22:08:37  Author:lautturi