DROP USER

Removes one or more user accounts.

Syntax

DROP USER [IF EXISTS] user [, user] ...
user:  
'user'[@'host_name']

Remarks

  • user - valid user account. The @'host_name' part is optional. If a hostname is not specified, @'%' will be appended to the user string. For example, 'demo-user' is equivalent to 'demo-user'@'%'.The '%' wildcard matches any hostname. user and host_name need not be quoted if they are legal as unquoted identifiers. Quotes must be used if a host_name string contains wildcard characters (such as %), or a user string contains special characters (such as space or -) or is a restricted keyword.

  • New login attempts from deleted users will fail. However, DROP USER does not automatically close open database connections of the users deleted. In other words, deleted users that are still logged in to the database can run SQL commands against the database. To prevent deleted users from accessing the database using existing active connections, manually log the deleted users off the database server using the KILL CONNECTION and KILL QUERY command.

  • Use GRANT to create a user account and assign privileges.

  • This command causes implicit commits. Refer to COMMIT for more information.

  • If If EXISTS is not specified, the command will fail if any user listed does not exist.

  • If IF EXISTS is specified, the command will still attempt to drop every user listed, even if some of the users listed do not exist.

  • Refer to the Permission Matrix for the required permission.

Example

DROP USER myAdmin;

Last modified: August 18, 2023

Was this article helpful?