Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use DROP USER statement in MySQL

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use the DROP USER sentence in MySQL, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The DROP USER statement in MySQL can be used to completely remove user accounts and their privileges from MySQL. But before using the drop user statement, you should revoke the user's privileges, or in other words, if the user does not have privileges, you can use the drop user statement to delete the user from the Mysql database server.

Syntax:

DROP USER 'user'@'host'

Parameters:

1. User: this is the user name of the user account to be deleted.

2. Host: this 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 four users in the MySQL database server, as follows:

We can use a drop user statement to delete a single user account, or we can delete multiple user accounts, as follows:

Delete a single user using the DROP user statement: to delete a user account with the user name "gfguser1", the DROP user statement should be executed 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 a time. To delete two user accounts "gfguser2" and "gfguser1" from the above table, execute the following delete user statement:

Syntax:

Output:

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

These are all the contents of how to use the DROP USER statement in MySQL. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report