Home>Article>Database> How to delete a user in mysql?

How to delete a user in mysql?

藏色散人
藏色散人 Original
2019-05-06 10:17:49 26097browse

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;

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';

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!

Statement:
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
Previous article:What is a mysql cursor? Next article:What is a mysql cursor?