Home > Backend Development > PHP Problem > What to do if php mysql error occurs

What to do if php mysql error occurs

藏色散人
Release: 2023-03-06 22:12:02
Original
2643 people have browsed it

php Mysql error solution: first check the problem of mysql_connect and mysql_pconnect; then write a phpinfo page; then start mysql and execute the command STATUS; finally modify php.ini and restart the server.

What to do if php mysql error occurs

Recommended: "PHP Video Tutorial"

Solution to the "No such file or directory" error when PHP connects to MySQL Method

Okay, let’s talk about the solution to the error when connecting to the MYSQL database.

1, first determine 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"

2, write On the phpinfo page, find mysql.default_socket, mysqli.default_socket, pdo_mysql.default_socket

3, start mysql (see note 2), execute the command STATUS; note down the value of UNIX socket

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), and change the three mentioned in 2 Change the value of the configuration item to the value 3.

Restart the server

The above is the detailed content of What to do if php mysql error occurs. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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