MySQL User Rights Assignment column

Source: Internet
Author: User
Tags new set

00x1 Create a new user

Created after logging in by the root user

Grant all privileges on * * to [e-mail protected] identified by "123456"; /Create a new user, username testuser, password is 123456;

Grant all privileges on * * to [e-mail protected] identified by "123456"; /set user testuser, can access MySQL locally

Grant all privileges on * * to [e-mail protected] "%" identified by "123456"; /set user testuser, can access MySQL remotely

Flush privileges; /mysql new set up user or change password after flush privileges refresh the MySQL system permission related table, otherwise there will be denied access, another way is to restart the MySQL server for the new settings to take effect

  

00x2 setting user access to database permissions

Grant all privileges the test_db.* to [e-mail protected] identified by "123456"; /set user testuser, only Access database test_db, other databases can not access;

Grant all privileges on * * to [e-mail protected] identified by "123456"; /set user testuser to access all databases on MySQL;

Grant all privileges the test_db.user_infor to [e-mail protected] identified by "123456"; /set user testuser, can only access the database test_db table User_infor, the other tables in the database can not be accessed;

  

00x3 Setting User Action Permissions

Grant all privileges on * * to [e-mail protected] identified by ' 123456 ' with GRANT OPTION; Set the user testuser, have all the operation rights, namely the Administrator;

Grant SELECT On *. * to [e-mail protected] identified by ' 123456 ' with GRANT OPTION; Set user testuser, only have "query" operation permission;

Grant Select,insert on * * to [e-mail protected] identified by "123456"; Set user testuser, only have "query \ Insert" Operation permission;

Grant Select,insert,update,delete on * * to [e-mail protected] identified by "123456"; Set user testuser, only have "query \ Insert" Operation permission;

REVOKE Select,insert on how from TestUser//Cancel user testuser "query \ Insert" Operation permission;

  

00x4 setting user remote access Permissions

Grant all privileges on * * to [e-mail protected] "192.168.1.100" identified by "123456"; Set user TestUser, only on the client IP is 192.168.1.100 to access MySQL remotely;

  

00x5 about the root user's access settings

Set all users can remotely access MySQL, modify the my.cnf configuration file, bind-address = 127.0.0.1 front Plus "#" comment out, so that you can allow other machines to remotely access the native MySQL;

Grant all privileges on * * to [e-mail protected] "%" identified by "123456"; /set user root to access MySQL remotely

Select Host,user from user; Querying all user rights in MySQL

Turn off root user remote access permission

Delete from user where user= "root" and host= "%"; Disable root user access to MySQL on remote machine

Flush privileges; After you modify the permissions, refresh the MySQL system permissions related table before it takes effect

Reproduced in: http://www.cnblogs.com/candle806/p/4048651.html

MySQL User Rights Assignment column

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.