MySQL revokes permissions and deletes user _ MySQL

Source: Internet
Author: User
MySQL revokes permissions and deletes user bitsCN.com

Cancel permissions and delete users in MySQL

As the database administrator, since users can be created and authorized, users can also be revoked and deleted. To cancel a user's permissions, you can use the REVOKE statement. The syntax format of this statement is as follows:

Revoke privileges (columns) on what from user ; 

Here, privileges is the permission to be canceled, and user is the user name to be revoked.

Example:

The following code cancels all permissions of sss users.

mysql> revoke all on *.* from sss@localhost ;Query OK, 0 rows affected (0.00 sec) 

The REVOKE statement can only cancel user permissions, but cannot delete users. Even if you cancel all permissions, you can still connect to the server. To completely DELETE a user, you must use the DELETE statement to DELETE the user's records from the user table in the MySQL database. The syntax format of this statement is as follows:

Delete from user where user = "user_name" and host = "host_name" ; 

Use DELETE to DELETE the sss user. the code is as follows:

mysql> use mysqlDatabase changedmysql> delete from user where user='sss' and host='localhost' ;mysql>flush privileges ;Query OK, 1 row affected (0.02 sec)

Delete is used to delete users. flush tells the server to reload the authorization table.

BitsCN.com

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.