Mysql_connect () "No such file or directory" troubleshooting, mysqlconnect
When LogAnalyzer is deployed, a mysql_connect () error is thrown by php!
Mysql_connect () function: http://www.w3school.com.cn/php/func_mysql_connect.asp
Host environment: PHP5.6.1, Nginx1.4.7, and Mysql5.5.40
In this case, the log query time throws this error, while other modules, such as adding and Deleting Users, are not affected,
Run the SQL statement select DeviceReportedTime, FromHost, Message from Syslog. SystemEvents to obtain normal data.
The problem is that php calls Mysql .......
Start troubleshooting:
1. Find the location where the mysql_connect () function is used in LogAnalyzer:
Http://phpcrossref.com/xref/loganalyzer/_functions/mysql_connect.html
4 In total
2. Find the configuration in config. php of LogAnalyzer.
If the name of a table is incorrect, you can change it to the correct one. Here, the system configuration file is modified;
Go to the database and modify the DBTableName field of the logcon_sources table in the Syslog database to the correct value;
3. Check whether the mysql_connect () function is correct.
(1) create a test. php
<Span style = "font-size: 14px;"> <? Php $ con = mysql_connect ("localhost", "syslog", "123456"); if (! $ Con) {die ('could not connect: '. mysql_error () ;}// some code... mysql_close ($ con);?> </Span>
When http: // localhost: 9189/test. php is used, only the "cocould not ....."
2. Confirm the problem in the previous step. Mysql also knows the location of UNIX socket.
Directly go to/etc/php. ini and modify the positions of the three Mysql-related nested functions.
<span style="font-size:14px;">mysql.default_socket =/mnt/mydata/mysql.sockmysqli.default_socket =/mnt/mydata/mysql.sockpdo_mysql.default_socket=/mnt/mydata/mysql.sock</span>
Restart php-fpm to solve the problem.
Summary:
1. The Code copied from the Internet should be carefully verified, even if it is open source;
2. When an error occurs, do not ask people everywhere. You should say that all programs are switched to the debug mode and be ruled out step by step!