Home > Database > Mysql Tutorial > body text

Detailed explanation of the use of DROP USER statement in MySQL

藏色散人
Release: 2019-03-13 11:45:20
Original
3574 people have browsed it

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.

Detailed explanation of the use of DROP USER statement in MySQL

Syntax:

DROP USER 'user'@'host';
Copy after login

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’
Copy after login

Assume there are 4 users in the MySQL database server as follows:

Detailed explanation of the use of DROP USER statement in MySQL

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:

Detailed explanation of the use of DROP USER statement in MySQL

Output:

The table after executing the drop user statement is as follows:

Detailed explanation of the use of DROP USER statement in MySQL

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:

Detailed explanation of the use of DROP USER statement in MySQL

Output :

The table after executing the above drop user statement is as follows:

Detailed explanation of the use of DROP USER statement in MySQL

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!