Home > Database > Mysql Tutorial > How to delete a user in mysql?

How to delete a user in mysql?

藏色散人
Release: 2020-10-12 14:54:42
Original
26232 people have browsed it

Mysql method to delete users: 1. Use the "drop user username;" command to delete; 2. Use the "delete from user where user='username' and host='localhost';" command to delete, Where localhost is the host name.

How to delete a user in mysql?

Mysql method of deleting users:

1. Drop deletion

drop user XXX;
Copy after login

Delete existing users. By default, the user 'XXX'@'%' is deleted. If there are other users such as 'XXX'@'localhost', etc., they 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. delete delete

delete from user where user='XXX' and host='localhost';
Copy after login

where XXX is the user name and localhost is the host name.

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 content in 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.

Related recommendations: "mysql tutorial"

The above is the detailed content of How to delete a user 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