1. In MySQL

To drop a user in a MySQL database, run this command:

DROP USER 'username'@'hostname';

The DROP USER statement removes the user along with its privileges.

If hostname is not specified, it will be set as default to '%'.

If you are not sure that user exists or not, add IF EXIST to the statement:

DROP USER  IF EXIST 'username'@'hostname';

DROP USER does not automatically close any currently open user sessions.

In case that you drop a user with an open session, the DROP USER statement does not take effect until that user’s session is closed. Once the session is closed, the user is dropped, and that user’s next attempt to log in will fail.


2. In PostgreSQL

To drop a user in PostgreSQL, the DROP USER statement has similar syntax to MySQL.

DROP USER  IF EXIST 'username'@'hostname';

Only superusers and users with the CREATEROLE privilege can remove PostgreSQL users. Or in other word, you can only remove a PostgreSQL user the you log in as a superuser.


New to TablePlus? It’s a modern, native tool with an elegant GUI that allows you to simultaneously manage multiple databases such as MySQL, PostgreSQL, SQLite, Microsoft SQL Server and more.


Download TablePlus here. It’s free anyway!

TablePlus GUI for MySQL