A brief analysis of the difference between drop user and delete from Mysql.user _mysql

Source: Internet
Author: User
Tags least privilege
Drop user deletes all of the user's information, and delete only clears the users table, and other information, such as the DB table, exists.
If you create a user with the least privilege after delete, then he reuses the previous permissions.
Grant all on test.* to ' test ' @ '% ' identified by ' test ';
Delete from user where user =test;
Look at DB table
Mysql> select * from DB;
+------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+---- --------+-----------------+------------+------------+-----------------------+------------------+--------------- ---+----------------+---------------------+--------------------+--------------+------------+--------------+
| Host | Db | User | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Create_tmp_table_priv | Lock_tables_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Execute_priv | Event_priv | Trigger_priv |
+------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+---- --------+-----------------+------------+------------+-----------------------+------------------+--------------- ---+----------------+---------------------+--------------------+--------------+------------+--------------+
| %    | test    |      | y           | y           | y           | y           | y           | y         | n          | y               | y          | y          | y                      | y                | y                | y              | y                   | n                  | n            | y          | y            |
| %    | test\_% |      | y           | y           | y           | y           | y           | y         | n          | y               | y          | y          | y                      | y                | Y                | y              | y                   | n                  | n            | y          | y            |
| %    | test    | Test | y           | y           | y           | y           | y           | y         | n          | y               | y          | y          | y                      | y                | y               | y              | y                   | y                  | y            | y          | y            |
+------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+---- --------+-----------------+------------+------------+-----------------------+------------------+--------------- ---+----------------+---------------------+--------------------+--------------+------------+--------------+
3 Rows in Set (0.00 sec)
Permission for test still exists
Create a user with only select test
Grant Select on test.* to ' test ' @ '% ' identified by ' test ';
Mysql> select * from DB;
+------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+---- --------+-----------------+------------+------------+-----------------------+------------------+--------------- ---+----------------+---------------------+--------------------+--------------+------------+--------------+
| Host | Db | User | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Create_tmp_table_priv | Lock_tables_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Execute_priv | Event_priv | Trigger_priv |
+------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+---- --------+-----------------+------------+------------+-----------------------+------------------+--------------- ---+----------------+---------------------+--------------------+--------------+------------+--------------+
| %    | test    |      | y           | y           | y           | y           | y           | y         | n          | y               | y          | y          | y                      | y                | y                | y              | y                   | n                  | n            | y          | y            |
| %    | test\_% |      | y           | y           | y           | y           | y           | y         | n          | y               | y          | y          | y                      | y                | Y                | y              | y                   | n                  | n            | y          | y            |
| %    | test    | Test | y           | y           | y           | y           | y           | y         | n          | y               | y          | y          | y                      | y                | y               | y              | y                   | y                  | y            | y          | y            |
+------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+---- --------+-----------------+------------+------------+-----------------------+------------------+--------------- ---+----------------+---------------------+--------------------+--------------+------------+--------------+
3 Rows in Set (0.00 sec)
permissions are the same as before.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.