Mysql user permission settings, remote access settings, set remote access from a fixed ip address, set root users to be unable to remotely access the mysql database, mysqlroot

Source: Internet
Author: User

Mysql user permission settings, remote access settings, set remote access from a fixed ip address, set root users to be unable to remotely access the mysql database, mysqlroot
For mysql user management, Note 1. Create a new user after logging on to the mysql console as the root user> grant all privileges on *. * to testuser @ localhost identified by "123456"; // create a new user. The username is testuser and the password is 123456.> grant all privileges on *. * to testuser @ localhost identified by "123456"; // sets the user testuser. You can access mysql locally> grant all privileges on *. * to testuser @ "%" identified by "123456"; // sets the user testuser. You can remotely access mysql> flush privileges; // mysql needs flush privileges to refresh the MySQL system permission table after setting a user or changing the password. Otherwise, access is denied. Another method is to restart the mysql server, to make the new settings take effect. 2. Set the user's database access permission> grant all privileges on test_db. * to testuser @ localhost identified by "123456"; // sets the user testuser, which can only access the database test_db, but cannot be accessed by other databases;> grant all privileges on *. * to testuser @ localhost identified by "123456"; // sets the user testuser to access all databases on mysql. >> grant all privileges on test_db.user_infor to testuser @ localhost identified by "123456"; // set the user testuser. Only the user_infor table of test_db can be accessed. No other tables in the database can be accessed; 3. Set User operation permissions> grant all privileges on *. * to testuser @ localhost identified by "123456" with grant option; // sets the user testuser, which has all the operation permissions, that is, the Administrator;> grant select on *. * to testuser @ localhost identified by "123456" with grant option; // sets the user testuser and only has the permission to perform the [query] operation.> grant select, insert on *. * to testuser @ localhost identified by "123456"; // sets the user testuser and only has the permission to [QUERY \ insert].> grant select, insert, update, delete on *. * to testuser @ localhost identified by "123456"; // sets the user testuser and only has the permission to [QUERY \ insert];> REVOKE select, insert ON what FROM testuser // cancel the [QUERY \ insert] operation permission of the user testuser; 4. Set the user's remote access permission (fixed IP address Remote Access)> grant all privileges on *. * to testuser @ "192.168.1.100" identified by "123456"; // sets the user testuser. You can remotely access mysql only when the client IP address is 192.168.1.100; 5. Concerning the root user access settings, all users can remotely access mysql and modify my. in the cnf configuration file, comment out "#" before bind-address = 127.0.0.1 to allow other machines to remotely access the local mysql instance.> grant all privileges on *. * to root @ "%" identified by "123456"; // set the user root. You can remotely access mysql> select host, user from user; // query all user permissions in mysql. Disable the remote access permission of the root user (adding confidentiality)> delete from user where user = "root" and host = "% "; // prohibit the root user from accessing mysql on a remote machine> flush privileges; // After modifying the permission, refresh the table related to MySQL's system permission to take effect.

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.