When the probe is used for phpinfo testing after installation. The default localhost is found to be unable to connect to the MARIADB database, but can be connected through 127.0.0.1. Said it was very depressing. The first thought was: is the Hosts file problem on the Linux server.
So, echo "127.0.0.1 localhost" >>/etc/hosts && sync.
The result is still the same, localhost cannot connect 127.0.0.1 can connect.
On the internet to see a friend said is SELinux problem, but, general system installed after I have SELinux set to permissive mode. So there is further set to Disabled mode. The result is the same.
Finally found is the relationship between PHP and MySQL, we only need to modify the php.ini configuration on it.
The Mysqld.sock file address is not specified in the php.ini configuration file for the default compilation installation, and it is looked up from the default in/var/run/mysqld/mysqld.sock. While compiling the installation of the MARIADB installation of the Mysqld.sock file in the/usr/local/mysql/tmp directory. and PHP through the localhost connection MySQL is exactly the way to use the Mysqld.sock to connect. Therefore, the above problems appear in our clear antecedents.
Below we view the local Mysqld.sock file location, write it to the php.ini configuration inside OK.
The most conservative approach is to execute the sync command for data writing. Then restart the apache2 server. In general, you do not have to execute these two commands. I have used it directly and cannot do any more tests.