The main clue to this problem is that you can't connect to the server through '/tmp/mysql.sock ', and PHP standard configuration is using '/tmp/mysql.sock ', but some MySQL installation method will mysql.sock in/var/lib/ Mysql.sock or any other place, you can modify the/etc/my.cnf file to correct it, open the file, you can see the following dongdong:
[Mysqld]
Socket=/var/lib/mysql.sock
The change is good, but also can cause other problems, such as MySQL program can't even, add a little:
[MySQL]
Socket=/tmp/mysql.sock
Or you can modify the configuration in the php.ini to make PHP use the other mysql.sock to connect, this everyone to find
Or in this way:
Ln-s/var/lib/mysql/mysql.sock/tmp/mysql.sock
And also:
phpMyAdmin's manual says
The error message "Warning:mysql Connection Failed:can ' t connect to local MySQL server through socket '/tmp/mysql.sock ' (a) ... "is displayed. What can I do?
For RedHat users, Harald Legner suggests the mailing list:
On my redhat-box the socket of MySQL Is/var/lib/mysql/mysql.sock. In your php.ini your'll find a line
Mysql.default_socket =/tmp/mysql.sock
Change it to
Mysql.default_socket =/var/lib/mysql/mysql.sock
Then restart Apache and it'll work.
Here are a fix suggested by Brad Ummer in the Phpwizard forum:
Need to determine what the socket is being used by MySQL.
To doing this, telnet to your server and go to the MySQL bin directory. In this directory there should is a file named Mysqladmin. Type./mysqladmin variables, and this should give you a bunch of info about your MySQL server, including the socket (/tmp/ Mysql.sock, for example).
Then, you are need to tell PHP to the use this socket.
Assuming you are a using PHP 3.0.10 or better, you can specify the "socket to" when you open the connection. To does this in phpMyAdmin, you need to complete the socket information in the CONFIG.INC.PHP3.
For example: $cfg [' Servers '] [$i] [' socket '] = '/tmp/mysql.sock ';