The Query
SELECT user, host FROM mysql.user;Each row is one account. An account is the pair of user name and host, so 'app_ and 'app_ are two separate accounts with their own passwords and privileges. localhost means connections from the server itself; % means any host.
Log In as an Administrator
Reading mysql.user needs an administrative account. On Ubuntu and Debian, the root account of the database usually logs in through the system's root user, without a password, as described in how to install MySQL on Ubuntu:
sudo mysqlWhere root has a password, let the client ask for it:
mysql -u root -pNever write the password after -p on the command line: it stays in your shell history and is visible to other users in the process list. From the shell, one query runs without opening the client:
sudo mysql -e "SELECT user, host FROM mysql.user;"More Useful Columns
SELECT user, host, plugin, account_locked FROM mysql.user;This form is for MySQL; on MariaDB, leave out account_, which its mysql.user view does not have. The plugin column shows how the account logs in:
- caching_
sha2_ the default password method in MySQL 8.0 and later.password: - auth_
socket: MySQL checks the Linux user that runs the client; this is howsudo mysqlworks for root on Ubuntu. - mysql_
native_ the older password method, disabled by default in MySQL 8.4 and removed in MySQL 9.0. MariaDB still supports it.password: - unix_
socket: MariaDB's plugin for login through the Linux user, used by root by default.
To see one account in full, end the query with \G instead of a semicolon: SELECT * FROM mysql.user WHERE user = 'app_ prints one column per line.
Which Account Am I Using?
SELECT USER(), CURRENT_USER();USER() shows the name and host you connected with. CURRENT_ shows the account MySQL matched, whose privileges apply. When they differ, for example a login matched by a % account, the second one is the one that counts.
Show the Privileges of an Account
SHOW GRANTS FOR 'app_user'@'localhost';
SHOW GRANTS;The first form shows another account; it needs both the name and the host. The second shows your own. A typical application account has ALL PRIVILEGES ON app.*, all rights on one database and nothing else. An application account with rights on *.* deserves a closer look.
System Accounts You Will See
Besides root and your own accounts, the list contains accounts the server creates for itself:
- mysql.sys, mysql.session, mysql.infoschema: reserved accounts on MySQL 8.0 and later. They are locked and cannot log in.
- mariadb.sys: the internal account on MariaDB, owner of the
mysql.userview. - debian-sys-maint: may appear on Debian and Ubuntu, used by the package scripts.
Leave all of them alone. Removing one can break upgrades or system views.
MariaDB Differences
On MariaDB, mysql.user is a view over the mysql.global_ table, and the query at the top works unchanged. Roles appear in the list too; on MariaDB they are marked by the is_ column. The client is called mariadb; the old name mysql still works through a link.
Remove an Account You No Longer Need
Before you drop an account, check with SHOW GRANTS what it can do and make sure no application still logs in with it: the application fails at its next connection. Then:
DROP USER 'old_app'@'localhost';This removes the account and its privileges, not its databases. To list the system users of the server rather than the database, see how to list users in Linux. To list databases, see how to list databases in MySQL.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations