MySQL common commands user's chapter

Source: Internet
Author: User

New User:

Create user username; --Create an empty password user.

Create user username identified by ' password '; -Create a password when creating a new user.

Grant Select[,insert ...] on Mysql.user to username identified by ' password '; --Create a new user and grant the user the right to select the MySQL database user table.


Update Password:

1. Set Password=password (' Password '); --modifies the current user password.

2. Set password for user name =password (' password '); --modifies the specified user password.

3. Update Mysql.user set Password=password (' Password ') where user= ' username '--Modified directly with update

Flush Privilegs; --Update the memory to make it effective


To view User rights:

Use MySQL

SELECT * from user where user= ' test ' \g; --Format to view the permissions of the test user.


To delete a user:

Delete from user where user= '; --Remove the User Name column from the Users table, and add the from. Prevent task users from being able to log in freely

Flush privileges; --Refresh the memory for the changes to take effect


To authorize the user:

Grant all on mysql.user to [email protected] '% '; --Give all permissions to the user table in the MySQL database for all users named Test.

Grant all on stu.* to [email protected] '% '; --Give all TEST2 users permission to the STU database


Query user permissions:

SELECT * from Mysql.user where user= ' random username '; --Querying user permissions at the database level

Show grants; --Query Current user permissions

Show grants for user name; --Query the permissions of the specified user


Change permissions:

Revoke all privileges in mysql.user from test; --Reclaims all the permissions of the test user on the Mysql.user data sheet.

Revoke select on Mysql.user from Test2; --Reclaim Test2 's SELECT permission on the Mysql.user data table.


MySQL common commands user's chapter

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.