This article mainly introduces the PHP connection is not MySQL but the MySQL command line operation of the normal solution, the need for friends can refer to the
Failure Status: PHP Web Connection MySQL failed, but at the command line through the MySQL command to log in and normal operation. Solution: 1. Login to MySQL at the command line, execute the following command: The code is as follows: Show variables like ' socket '; After execution, it will be similar to the following echo: The code reads: "Variable_name" "Value" "Socket" "/home/mysql/data/mysql.sock" 2, edit php.ini, find To the Mysql.default_socket configuration item, the default is generally null (using the sock path set when editing MySQL) to add the value to the "/home/mysql/data/mysql.sock" in the above Echo: The code is as follows:; Default socket name for the local MySQL connects. If empty, uses the built-in; MySQL defaults. Mysql.default_socket =/home/mysql/data/mysql.sock 3, restart PHP.