MySQL Allow remote connection authorization method

Source: Internet
Author: User

MySQL database and Apache are not on the same server, you need to connect to MySQL remotely, this requires MySQL remote connection authorization, in order to secure only some IP can connect:

If you want the root user to connect to MySQL from IP 192.168.2.12 and set the password "123456", the authorization method is as follows:

1, enter mysql:mysql>grant all privileges on * * to ' root ' @ ' 192.168.2.12 ' identified by ' 123456 ' with GRANT OPTION;

Mysql>flush Privileges

2, in the 192.168.2.12 server can use the command can be remote connection MySQL, but found that the connection is not connected with the code, check the reason, found that the database server restarted, Httpd_can_newwork_connect will become 0, Causes the network to not connect to

HTTPD service, you need to turn it on:

Setsebool-p httpd_can_network_connect=1

3,php can connect to the remote database normally

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.