mysql_connect prompts 'No such file or directory' error_PHP tutorial

WBOY
Release: 2016-07-13 10:56:55
Original
1555 people have browsed it

Some friends will get the No such file or directory error message when using mysql connection. Let me summarize the solutions below.

Connection code

2. Write a phpinfo page and find mysql.default_socket, mysqli.default_socket, and pdo_mysql.default_socket. 3. Start mysql and execute the command STATUS; note the value of the UNIX socket.
The code is as follows
 代码如下 复制代码

$this->linkid = @mysql_pconnect($host, $user, $password) or die(mysql_error());

Copy code


$this->linkid = @mysql_pconnect($host, $user, $password) or die(mysql_error());

Make a phpinfo() page. Look for ‘mysql.default_socket‘, ‘mysqli.default_socket‘, and

‘pdo_mysql.default_socket‘. Remember their value; this is where PHP is trying to connect to MySQL.



Solution

1. First of all, it is determined that it is a problem with mysql_connect() and mysql_pconnect(). The fault phenomenon is that the function returns empty and mysql_error() returns "No

such file or directory".
4. If the values ​​​​of 2 and 3 are different, open php.ini (the location of php.ini can be found from the phpinfo page, the default is /private/etc/php.ini)

, change the values ​​of the three configuration items mentioned in 2 to the values ​​of 3.

5. Restart apache. http://www.bkjia.com/PHPjc/632137.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/632137.html
TechArticle
Some friends will get the No such file or directory error message when using mysql connection. Let me summarize the solutions below. Connection code The code is as follows Copy code $this-linkid = @mysql_pc...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template