Fault status: the php website fails to connect to mysql. However, you can use the mysql command in the command line to log on and operate normally.
Solution:
1. log on to mysql under the command line and execute the following command:
Copy codeThe Code is as follows: show variables like 'socket ';
After the command is executed, the echo is similar to the following:
Copy codeThe Code is as follows:
"Variable_name" "Value"
"Socket" "/home/mysql/data/mysql. sock"
2. Edit php. ini, find mysql. default_socket configuration item. The default value is generally null (use the sock path set when you edit Mysql). add this item to "/home/mysql/data/mysql" in the preceding echo. sock ":
Copy codeThe Code is as follows:
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL ults.
Mysql. default_socket =/home/mysql/data/mysql. sock
3. Restart php.