Solve the problem that PHP cannot access remote mysql. The remote server can be accessed remotely. The problem I encountered was as follows: there are three servers A, B, and C, and C is the server. B can use PHP to successfully connect to mysql on Machine C, remote servers can be accessed remotely.
The problem I encountered was: there are three servers A, B, and C, and C is the server. B can use PHP to successfully connect to mysql on Machine C, while machine A cannot connect!
It can be said that it is certainly not a problem with the code, and the mysql settings on the server are also OK, because the B server can all be used.
It must have been A problem with Machine A's settings!
I searched on the internet and found that mysql authorization problems, php. ini modification, and firewall modification were not actually caused by these problems.
Finally, I thought about the SELINUX problem. I compared the two AB machines and set them differently! It's probably a problem!
The following settings are made:
Root, use vim to open the file/etc/selinux/config
Modify the value of SELINUX:
# SELINUX = enforcing
SELINUX = disabled
Save and exit.
Restart takes effect. if you do not want to restart, enter the command line
Setenforce 0
Press enter, OK
Bytes. The problem I encountered was: there are three servers A, B, and C, and C is the server. B can use PHP to successfully connect to mysql on Machine C, while machine...