To delete or remove a MySQL or MariaDB user account on Linux or Unix, you can use the DROP USER
command. Here’s how to delete a MySQL or MariaDB user account:
- Connect to the MySQL or MariaDB database as a user with sufficient privileges:
mysql -u <username> -p
where
<username>
is the name of the user account with sufficient privileges. - Execute the
DROP USER
command:DROP USER '<user-to-be-deleted>'@'<hostname>';
where
<user-to-be-deleted>
is the name of the user account to be deleted, and<hostname>
is the hostname of the computer where the user is allowed to connect. - Flush the privileges to make the changes take effect:
FLUSH PRIVILEGES;
- Exit the MySQL or MariaDB shell:
exit;
Now, the specified user account has been deleted, and it will no longer be able to connect to the database.