解决不能通过mysql.sock连接MySQL问题的办法
这个问题主要提示是,不能通过'/tmp/mysql.sock'连到服务器,而php标准配置正是用过'/tmp/mysql.sock',但是一些mysql安装方法将mysql.sock放在/var/lib/mysql.sock或者其他的什么地方,你可以通过修改/etc/my.cnf文件来修正它,打开文件,可以看到如下的东东:
,|.x&t%n$r%o;D&D x o;q [mysqld] 0M.} d7L-g1Z,h5d(l6f
socket=/var/lib/mysql.sock
1e,{%e7Y-i7M-T0S 改一下就好了,但也会引起其他的问题,如mysql程序连不上了,再加一点:
#N!j6y*N$?'_ [mysql]
$Q9A;f8O+_ socket=/tmp/mysql.sock tech.techweb.com.cn)f8Y;w6r#`
或者还可以通过修改php.ini中的配置来使php用其他的mysql.sock来连,这个大家自己去找找
)t;z/Z4W"s+[7G
Z!C3W-r;c 或者用这样的方法:
9P5t5F%@(}1e+H Y1N ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
$\#J1y8i$n3O5a程序开发,操作系统,服务器,源码下载,Linux,Unix,BSD,PHP,Apach,asp,下载,源码,黑客,安全,技术社区,技术论坛
-~-{*E5j9v-|&~:v.H!S0KTechWeb-技术社区 还有:
,Q*W#t5C6d'_*?&\4~程序开发,操作系统,服务器,源码下载,Linux,Unix,BSD,PHP,Apach,asp,下载,源码,黑客,安全,技术社区,技术论坛 phpmyadmin的说明书有说 2R d1{;j"`6o1_0^6`
The error message "Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)..." is displayed. What can I do?
1e6Z.j*Z4p8d'W)F
9u-w.}+a4B For RedHat users, Harald Legner suggests this on the mailing list:
;a;g%j5C+j;Ntech.techweb.com.cn 9Z*T2]+G9c:E;[6a
On my RedHat-Box the socket of mysql is /var/lib/mysql/mysql.sock. In your php.ini you will find a line ']6c-N8H%\*E+n7w
mysql.default_socket = /tmp/mysql.sock 程序开发,操作系统,服务器,源码下载,Linux,Unix,BSD,PHP,Apach,asp,下载,源码,黑客,安全,技术社区,技术论坛.r0e.}*x(x-B
change it to (H&D.t-z9`&E
mysql.default_socket = /var/lib/mysql/mysql.sock
,E)h,g(O9lTechWeb-技术社区 Then restart apache and it will work.
7J R+d"B:\6d5y9}/_tech.techweb.com.cn
5G9Y%g1T F0Z3X)u Here is a fix suggested by Brad Ummer in the phpwizard forum:
z)u7M/z6O9I&J6C
%\%`)P)d)h5T.Y1F3I"F First, you need to determine what socket is being used by MySQL.
+p3{/~9S8J)s.n To do this, telnet to your server and go to the MySQL bin directory. In this directory there should be 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).
6f:h1U3N*h#P9C.B,I9e Then, you need to tell PHP to use this socket.
*p6S#r6D)I6K;oTechWeb-技术社区 Assuming you are using PHP 3.0.10 or better, you can specify the socket to use when you open the connection. To do this in phpMyAdmin, you need to complete the socket information in the config.inc.php3. 1Y7Q"`4_"@)r!T"h4k
For example: $cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock';
|