How to delete or remove a MySQL/MariaDB user account on Linux/Unix
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> -pwhere
<username>is the name of the user account with sufficient privileges. - Execute the
DROP USERcommand: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;
