Mysql_connect () "No such file or directory" troubleshooting, mysqlconnect

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.