Home>Article>Database> How to delete mysql username

How to delete mysql username

全球HTTP
全球HTTP Original
2020-09-25 16:12:08 5307browse

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'@'%'这个用户

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为主机名

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!

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:mysql query database size Next article:mysql query database size