Home > Database > Mysql Tutorial > body text

How to delete mysql username

全球HTTP
Release: 2020-09-27 11:20:43
Original
5216 people have browsed it

Method to delete mysql user name: 1. Use drop to delete, the syntax is [drop user XXX; delete existing user]; 2. Use delete to delete, the syntax is [delete from user where user='XXX ' and host='..'].

How to delete mysql username

Related learning recommendations: mysql database

Method to delete mysql username:

1. Use drop to delete

drop user XXX;删除已存在的用户,默认删除的是'XXX'@'%'这个用户
Copy after login

If there are other users such as 'XXX'@'localhost', etc. , will not be deleted together. If you want to delete 'XXX'@'localhost', you need to add host when using drop to delete, that is, drop user 'XXX'@'localhost'.

2. Use delete to delete

delete from user where user='XXX' and host='localhost';其中XXX为用户名,localhost为主机名
Copy after login

3. Difference

drop will not only delete the data in the user table, but also delete the contents of other permission tables.

Delete only deletes the contents of the user table, so after using delete to delete a user, you need to execute FLUSH PRIVILEGES; to refresh the permissions, otherwise an error will be reported the next time you use the create statement to create a user.

The above is the detailed content of How to delete mysql username. 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
Latest Articles by Author
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!