The DROP USER statement in MySQL can be used to completely remove a user account and its privileges from MySQL. But before using the drop user statement, the user's privileges should be revoked, or in other words, if the user does not have the privileges, then the user can be deleted from the Mysql database server using the drop user statement.
Syntax:
DROP USER 'user'@'host';
Parameters:
1. user: This is the username of the user account to be deleted.
2. host: It is the host server name of the user account. The username should be in the following format
‘user_name’@’host_name’
Assume there are 4 users in the MySQL database server as follows:
We can delete using a drop user statement A single user account, or multiple user accounts can be deleted, as shown below:
Use the DROP user statement to delete a single user: To delete the user account with the user name "gfguser1", you should execute the DROP user statement as follows:
Syntax:
Output:
The table after executing the drop user statement is as follows:
Use the DROP USER statement to delete multiple users: You can use the DROP USER statement to delete multiple user accounts at one time. To delete the two user accounts "gfguser2" and "gfguser1" from the above table, you should execute the following delete user statement:
Syntax:
Output :
The table after executing the above drop user statement is as follows:
Recommended related mysql video tutorials: "mysql tutorial"
This article is a detailed explanation of the use of the DROP USER statement in MySQL. I hope it will be helpful to friends in need!
The above is the detailed content of Detailed explanation of the use of DROP USER statement in MySQL. For more information, please follow other related articles on the PHP Chinese website!