Linux under MySQL command

Source: Internet
Author: User

1, enter MySQL, terminal input mysql-u user name-P. The ENTER key prompts you for a password.

2, execute grant all privileges on xxxdb.* to [email protected] '% ' identified by ' passdtest '; Add user usertest, password is passdtest. It has all permissions on the database xxxdb. can be accessed outside the network.

3,show database; To display the database under this user

4,select host,user from user; To view a user's permissions

1. 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, the user name is TestUser, the password is 123456;

>> Grant all privileges on * * to [e-mail protected] identified by "123456"; Set up user testuser to access MySQL locally

>> Grant all privileges on * * to [email protected] '% ' identified by "123456"; Set user testuser to remotely access MySQL

>> flush Privileges; MySQL new setup user or change password after use flush privileges refresh the MySQL system permission related table, otherwise there will be denied access, another way is to restart the MySQL server, to make the new settings take effect

  

2. Set user access to database permissions

>> Grant all privileges the test_db.* to [e-mail protected] identified by "123456"; Set user TestUser, can only access the 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;

  

3. Set User operation 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;

  

4. Set 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;

  

5, 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 [email 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

Linux under MySQL 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.