Open In App

MySQL | DROP USER

The DROP USER statement in MySQL can be used to remove a user account along with its privileges from the MySQL completely.But before using the drop user statement, the privileges of the user should be revoked or in other words, if a user has no privileges then the drop user statement can be used to remove a user from the Mysql database server.

Syntax:



DROP USER 'user'@'host';

Parameters:
1. User:It is the user name of the user account you want to drop.
2. Host:It is the host server name of the user account.The user name should be in the following format
‘user_name’@’host_name’.

Suppose there are 4 users in the MySQL database server as listed below:




We can drop a single user account as well as multiple user accounts using a single DROP USER statement as shown below:

Note: In case the DROP USER statement is executed for an user account when the session for this account is active then it will not effect that account until it’s session gets closed. The user account will be dropped after its session gets closed and will not be able to login any more.

References:

Article Tags :
SQL