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.
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!