mySQL / MariaDB - Delete user account using the DROP USER statement

by
Jeremy Canfield |
Updated: November 01 2021
| mySQL / MariaDB articles
This assume you are able to log into your MariaDB or mySQL server or you have configured passwordless authentication and wil be using the -e command line option and the user must have the Drop_priv.
mysql -e "select User,Host,Drop_priv from mysql.user where User = 'root' and Host = 'localhost' \G"
*************************** 1. row ***************************
User: root
Host: localhost
Drop_priv: Y
You may want to first SELECT USER to display the list of current users to ensure the user account you want to drop exists. In this example, 'john.doe'@'localhost' exists.
mysql -e "select User,Host from mysql.user \G"
*************************** 1. row ***************************
User: root
Host: %
*************************** 2. row ***************************
User: john.doe
Host: localhost
*************************** 3. row ***************************
User: mariadb.sys
Host: localhost
*************************** 4. row ***************************
User: root
Host: localhost
And here is how you would delete 'john.doe'@'localhost'.
mysql -e "drop user 'john.doe'@'localhost'"
Did you find this article helpful?
If so, consider buying me a coffee over at