欢迎光临
我们一直在努力

解决不能通过mysql.sock连接MySQL问题的办法-PHP教程,PHP应用

建站超值云服务器,限时71元/月

这个问题主要提示是,不能通过/tmp/mysql.sock连到服务器,而php标准配置正是用过/tmp/mysql.sock,但是一些mysql安装方法将mysql.sock放在/var/lib/mysql.sock或者其他的什么地方,你可以通过修改/etc/my.cnf文件来修正它,打开文件,可以看到如下的东东:

[mysqld]

socket=/var/lib/mysql.sock

改一下就好了,但也会引起其他的问题,如mysql程序连不上了,再加一点:

[mysql]

socket=/tmp/mysql.sock

或者还可以通过修改php.ini中的配置来使php用其他的mysql.sock来连,这个大家自己去找找

或者用这样的方法:

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

还有:

phpmyadmin的说明书有说

the error message "warning: mysql connection failed: cant connect to local mysql server through socket /tmp/mysql.sock (111)…" is displayed. what can i do?

for redhat users, harald legner suggests this on the mailing list:

on my redhat-box the socket of mysql is /var/lib/mysql/mysql.sock. in your php.ini you will 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 will work.

here is a fix suggested by brad ummer in the phpwizard forum:

first, you need to determine what socket is being used by mysql.

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).

then, you need to tell php to use this socket.

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.

for example: $cfg[servers][$i][socket] = /tmp/mysql.sock;

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 解决不能通过mysql.sock连接MySQL问题的办法-PHP教程,PHP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章