MySQL DROP User

  • The DROP USER statement is used to remove user accounts from MySQL. It removes privilege rows for the account from all grant tables.
  • To use DROP USER, we must have the global CREATE USER privilege, or the DELETE privilege for the mysql database. When the read_only system variable is enabled, DROP USER additionally requires the SUPER privilege.

MySQL DROP User Syntax:

DROP USER [IF EXISTS] user [, user] ...

Example:

Drop user admin1

mysql> select User from user; +------------------+ | User | +------------------+ | phpadmin | | admin | | admin1 | | debian-sys-maint | | mgeorge | | mysql.session | | mysql.sys | | root | | skalpesh | +------------------+

mysql> DROP USER 'admin1'@'localhost'; Query OK, 0 rows affected (0.00 sec)

2. Verify the User is dropped or not.

mysql> select User from user; +------------------+ | User | +------------------+ | phpadmin | | admin | | debian-sys-maint | | mgeorge | | mysql.session | | mysql.sys | | root | | skalpesh | +------------------+