全球主机交流论坛

标题: 求解惑Mysql的localhost [打印本页]

作者: zjsz007    时间: 2012-4-22 16:26
标题: 求解惑Mysql的localhost
PHP 5.3.10
Mysql的localhost不能用,127.0.0.1可以.
在ssh里都可以进.
忙了一下午..搜到的结果是 原因:php5.3后,不支持连接mysql地址用“localhost”,连接地址要改用“127.0.0.1”

请问是这个原因吗?

作者: Kvm    时间: 2012-4-22 16:27
进mysql的帐户管理里面看 看
作者: zc035    时间: 2012-4-22 16:28
这个与 mysql 有关。另外。也可能和你的机器有关,

需要能解析 localhost => 127.0.0.1

一般的。 PING localhost 会得到 127.0.0.1 ,部分修改的不行。当然,这个还和 MYSQL 的登陆限制有关。
作者: enj0y    时间: 2012-4-22 16:29
提示: 作者被禁止或删除 内容自动屏蔽
作者: smollett    时间: 2012-4-22 16:32
zc035 发表于 2012-4-22 16:28
这个与 mysql 有关。另外。也可能和你的机器有关,

需要能解析 localhost => 127.0.0.1


作者: Kokgog    时间: 2012-4-22 16:38
应该和127.0.0.1没关系的
mysql host是 localhost的时候,  php会走unix socket
如果你php或者mysql是自己编译的, 没指定--with-mysql-sock或者php没找到默认的mysql-sock路径, 你连localhost的时候就爆浆了

作者: Kokgog    时间: 2012-4-22 16:40
去翻了下文档, 果然

Note:

Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as in your PHP configuration and leave the server field blank.
作者: 喝雪碧的虾    时间: 2012-4-22 16:52
hosts里面要解析一下吧。PHP5.3有很多问题的,建议别用
作者: zc035    时间: 2012-4-22 16:55
本人表示,我使用 php 5.3.10 , mysql 使用 localhost 连接一切正常。

当然。我的 都是 ping localhost => 127.0.0.1 ,另外。mysql 的用户没限制连接。
作者: 有个就好    时间: 2012-4-22 17:02
my.cnf可以限制
作者: zjsz007    时间: 2012-4-22 17:21
解决了,my.cnf定义的socket位置和编译mysql时候的位置不同.....
作者: javaluo    时间: 2012-4-22 18:08
Kokgog 发表于 2012-4-22 16:38
应该和127.0.0.1没关系的
mysql host是 localhost的时候,  php会走unix socket
如果你php或者mysql是自己编 ...

我爱你
作者: mope007    时间: 2012-4-22 18:36
学习了~




欢迎光临 全球主机交流论坛 (https://loc.niceguy.workers.dev/) Powered by Discuz! X3.4