MySQL Set Remote access

Source: Internet
Author: User

MySQL remote access, that is, through IP access to the MySQL service, MySQL requirements for security is very strict and requires authorization.

1. Local Access

SQL code
    1. GRANT All privileges on * * to [e- Mail protected] identified by ' admin ' with GRANT OP   tion;
    2. FLUSH privileges;



The above command means for admin user authorization, to access the database in localhost , password is admin, this is our recommended way of access, do not directly expose IP, improve the security of the database server.

2. Remote Access
If the database server and the application server physically split, that is not the same server, we need to access IP, this IP is the database server host IP.

SQL code
    1. GRANT All privileges on * * to [e- Mail protected] identified by ' admin ' with GRANT option;
    2. FLUSH privileges;



Of course, this grants Admin user with grant OPTION permission, less than secure! If a user modifies the database table structure from remote login and so on, it is very risky!

It is generally not recommended to grant rights to other users, namely:

SQL code
    1. GRANT all privileges on * * to [email protected] identified by ' admin ';
    2. FLUSH privileges;



3. Any Access
If you do not restrict IP access, authorizing a user to access the service with any IP, you can write:

SQL code
    1. GRANT all privileges on * * to [email protected]'% ' identified by ' admin ';
    2. FLUSH privileges;



Note Single Quotes!

3. Cancellation of Authorization
Of course, with authorization, there must be a cancellation authorization:

SQL code
      1. revoke  all on *.* from [email  protected];   
      2. flush privileges;  
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.