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

What to do if php mysql error occurs

藏色散人
藏色散人Original
2020-11-02 10:04:102607browse

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!

Statement:
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