A MySQL administrator can remove a database login from an SSH session using DROP USER. This guide explains how to identify the exact user and host entry before removing it.

Before you start

Check which applications use the login and move them to another appropriately authorised user first. Review its grants and any views, routines or other objects that use it as a definer.

If cPanel or another control panel owns the database user, use that panel’s supported user removal method to keep its account mapping consistent.

Connect and identify the account

Connect to the server through SSH, then open MySQL using an account with the required database administration privileges. For a password-based administrator login:

mysql -u adminuser -p

Replace adminuser with the authorised MySQL account. SSH access alone does not grant database administration privileges.

List the relevant user-host entries:

SELECT User, Host FROM mysql.user WHERE User = 'appuser';

MySQL treats 'appuser'@'localhost' and 'appuser'@'192.0.2.20' as separate accounts. Review the selected account’s grants:

SHOW GRANTS FOR 'appuser'@'localhost';

Remove the exact user-host entry

Run the following only for the confirmed account:

DROP USER 'appuser'@'localhost';

Check for errors, repeat the account lookup and test the affected applications. Existing sessions may remain until they disconnect, so a current connection alone is not a sufficient test.

DROP USER does not delete the application’s database tables. Do not delete rows directly from MySQL’s grant tables; FLUSH PRIVILEGES is not required after DROP USER.