Updated: 28 September 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9
MariaDB and MySQL store accounts in the mysql.user table. These queries work on MariaDB 10.x/11.x and MySQL 8.x.
Log in
sudo mariadb # or: mysql -u root -p
List users
SELECT User, Host FROM mysql.user; SELECT User, Host, plugin FROM mysql.user; -- also the login method SELECT DISTINCT User FROM mysql.user; -- names only
A user is the combination of name and host: 'shop'@'localhost' and 'shop'@'%' are two different accounts.
See what a user may do
SHOW GRANTS FOR 'shop'@'localhost'; SELECT CURRENT_USER(); -- who you are logged in as
Create and remove users
CREATE USER 'shop'@'localhost' IDENTIFIED BY 'Strong-Password'; GRANT ALL PRIVILEGES ON shopdb.* TO 'shop'@'localhost'; DROP USER 'olduser'@'localhost';
Note: On cPanel hosting, manage databases in cPanel with Databases › MySQL® Databases and phpMyAdmin; server-level changes are made by the server administrator.
Change a password or remove access
ALTER USER 'shop'@'localhost' IDENTIFIED BY 'New-Strong-Password'; REVOKE ALL PRIVILEGES ON shopdb.* FROM 'shop'@'localhost';
Find accounts that can connect from any host (%) with SELECT User, Host FROM mysql.user WHERE Host = '%'; and check that each one really needs remote access.