MySQL new, delete user and rights Assignment _mysql

Source: Internet
Author: User

1. New Users

Copy Code code as follows:

Mysql>insert into Mysql.user (Host,user,password) VALUES ("localhost", "Lionbule", Password ("hello1234"));
Mysql>flush privileges;

2. Modify User Password

Copy Code code as follows:

Mysql>update Mysql.user Set Password=password (' New password ') where user= "Lionbule" and host= "localhost";
Mysql>flush privileges;

3. Delete User

Copy Code code as follows:

Mysql>delete from user WHERE user= "lionbule" and host= "localhost";
Mysql>flush privileges;

4. Permission Assignment

4.1. Grant Usage
Grant permission on database. * To User name @ ' login host ' identified by ' password '

Copy Code code as follows:

Permissions:
Common Summary, All/alter/create/drop/select/update/delete
Database:
*.* represents all tables for all libraries
Test.* represents all tables of the test library
Test.test_table represents the Test_table table of the test library
User name:
MySQL account name
Login Host:
Allow client IP to log on to MySQL server
'% ' means all IP
' localhost ' means this machine
' 192.168.10.2 ' specific IP
Password:
Account corresponding Login password

4.2 Examples

Copy Code code as follows:

Mysql>grant all in test.* to lionbule@ '% ' identified by ' hello1234 ';
Mysql>flush privileges;

The new password is ' hello234 ' user lionbule has all the operation rights to the test library, does not restrict the Lionbule user's Landing IP.

4.3 points to note

Grant overwrites some of the user's information, as it does with the INSERT and update functions.

Reference:
Http://dev.mysql.com/doc/refman/5.6/en/grant.html

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.