现在的位置: 首页 > 综合 > 正文

Openbsd 下面 mysql 报错socket ‘/var/run/mysql/mysql.sock

2013年10月13日 ⁄ 综合 ⁄ 共 472字 ⁄ 字号 评论关闭

#2002 - Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)

 


道理很简单,因为你的mysql_connect是一个localhost,而不是你服务器的名字,如
果是localhost, PHP就会用mysql.sock文件,而不用正常的TCP连接。
apache在OpenBSD下都是chroot过了,这一点你可以 ps agx | grep httpd | grep parent 看到,chroot过apache根目录在/var/www,而你的mysql mysql.sock 文件在/var/run/mysql.

有两个解决方案:
1。mysql_connect 不用localhost,而是你的服务器名字www.yourserver.blablabla
2. 在 /etc/rc.conf 里的httpd,加"-u" httpd_flags="-u" 这样apache就不chroot了,不过我不喜欢这个方案,不安全。。。

man chroot , man rc.conf

抱歉!评论已关闭.