MySQL user management and Rights management

Source: Internet
Author: User

MySQL creates a new user:

CREATE USER username identified by ' password ';

Assign all permissions to the new user:

GRANT all privileges on * * to ' username ' @ ' localhost ' identified by ' password ';

To modify a user's permissions, first cut back to the root user and then use the following command (revoke the permissions of the new user and re-authorize):

Evoke all privileges on * * from ' username ' @ ' localhost '; GRANT all privileges the databasename.* to ' username ' @ ' localhost ' identified by ' password ';


You can also add only partial permissions to the user.

eg

To assign users only the Select and update permissions:

GRANT SELECT, UPDATE on databasename.* to ' username ' @ ' localhost ' identified by ' password ';

You need to refresh after assigning permissions:

FLUSH privileges;



To delete a user:

@>mysql-u root-p @> password mysql>delete from user Where user= ' username ' and host= ' localhost '; Mysql>flush privileges; Mysql>drop database databasename;        Delete User's database Delete account and permissions: >drop user [email protected] '% '; >drop user [email protected];


change user password:

@>mysql-u root-p@> password mysql>update mysql.user set Password=password (' New password ') where user= "username" and host= " localhost "; mysql>flush privileges;


MySQL user management and Rights management

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.