First of all, the remote server can be accessed remotely.
The problem I encountered is this: There are three servers A, B, and C. C is the server. B can successfully connect to the mysql of C machine using PHP, but machine A cannot connect!
It can be said that there is definitely no problem with the code, and there is no problem with the mysql settings on the server, because machine B is fine.
There must be something wrong with the settings of machine A!
After searching on the Internet, there are various reports about mysql authorization issues, modifications to php.ini, and modifications to the firewall. In fact, these problems are not caused.
Similar to the issues discussed on this page, but no one gave the results, link: http://bbs.csdn.net/topics/90284141
Finally, I thought of the SELINUX issue and compared the two AB machines. The machine, indeed the settings are different! I guess that's the problem with it, it's fun!
The following settings have been made:
Under root, use vim to open the file /etc/selinux/config
Modify the value of SELINUX:
#SELINUX=enforcing
SELINUX =disabled
Save and exit.
Restart will take effect. If you do not want to restart, enter
setenforce 0 on the command line
Press Enter, OK
Reference for modification here: http://www.xiaojb.com/archives/tips/disabled-selinux .shtml
Finally, the connection is successful, oh yeah! ! !