MySQL creates the user and specifies the user's permissions (Grant command)

Source: Internet
Author: User

Reference link http://blog.csdn.net/leili0806/article/details/8573636, thank you for this guy. 1. Create a new user's SQL statement:

CREATE USER ' pig ' @ ' 192.168.1.101_ ' idendified by ' 123456 ';

Pig is the user name , followed by the specified IP( If no limit can be changed to "%" after a ip,@), by the password

2. Set permissions for this user, using the GRANT statement

( such as restricting a user to query only, cannot modify, or restrict to query only specific tables )

Grammar:

mysql> Grant permissions 1, permissions 2,... Permission n on the database name . Table name to User name @ user address identified by ' connection password ';

Optional list of permissions:Select, INSERT, UPDATE, delete, create, drop,

Index, alter, Grant, references, Reload,

shutdown, process, file , etc. 14 permissions

eg

1. mysql> Grant Select,insert,update,delete,create,drop on Vtdc.employee to [email protected] Identified by ' 123 ';

Assign user Joe from 10.163.225.87 to the employee table VTDC the database

Do the Select,insert,update,delete,create,drop, and set the password to 123.

2. mysql>grant all privileges in vtdc.* to [e-mail protected] identified by ' 123 ';

For users from 10.163.225.87, Joe assigns permissions to all operations on the database VTDC all tables, and sets the password to 123.

3. Mysql>grant All privileges on * * to [e-mail protected] identified by ' 123 ';

For users from 10.163.225.87, Joe assigns permissions to all the tables in all databases and sets the password to 123.

4. Mysql>grant All privileges on * * to [e-mail protected] identified by ' 123 ';

Assign the native user Joe permission to all operations on all tables in all databases, and set the password to 123.

5. Mysql>flush Privileges; //Refresh System Permissions Table

MySQL creates the user and specifies the user's permissions (Grant command)

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.