简体   繁体   中英

Cannot connect to MySQL instance on server 1 from Apache in server 2

I have a MySQL server (Centos 6.7) which is hosting my database. This is a production server and there are several vb.net apps throughout the business which connect to it, as well as some other internal-only sites hosted on the MySQL box itself.

I have a web server (Centos 6.7) which is hosting an external site. This site needs to talk to the MySQL server, which I am trying to achieve via MySQLi, however no matter what I try, all I keep getting is

 Can't connect to MySQL server on '[MY-MYSQL-SVR-HOSTNAME]'

I have made sure that MySQL is running - It is.

I have flushed the firewall rules and even disabled the firewall, so that shouldnt be interfering.

I have made sure the user I am connecting as has the appropriate permissions to connect from % (any host), which is does.

I have also made sure that the mysqli module for PHP is installed and good to go.

I'm at a bit of a loss as to what to try next; any help is appriciated.

So the issue turned out to be SELINUX, specifically this bit...

 setsebool -P httpd_can_network_connect=1

I've set SELINUX to permissive for now and its working! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM