免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8039 | 回复: 8
打印 上一主题 下一主题

为什么localhost无法连接mysql [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-11-28 17:47 |只看该作者 |倒序浏览
最近有点奇怪,我在提示符下可以使用
mysql -u root -p
进行登录.
但是在PHP里面如果host 设置成 localhost就是连不上去.
非得设置成127.0.0.1才行!
但是/etc/hosts文件是也有127.0.0.1到localhost的映射.
特此请教.

论坛徽章:
0
2 [报告]
发表于 2006-11-29 13:41 |只看该作者
ping localhost看有东西没?

论坛徽章:
0
3 [报告]
发表于 2006-12-01 13:13 |只看该作者
[root@WEB phpmyadmin]# ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=0 ttl=64 time=0.055 ms
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.042 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.040 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.052 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.046 ms

论坛徽章:
0
4 [报告]
发表于 2006-12-01 15:53 |只看该作者
错误信息=?

论坛徽章:
0
5 [报告]
发表于 2006-12-01 16:01 |只看该作者
我遇见个更怪的!我在本机能用root登陆。在远程不能!现在急啊!mysql-font做的。错误是1045
做了grant。做了set old密码。还是不行。非常郁闷。

论坛徽章:
0
6 [报告]
发表于 2006-12-03 03:34 |只看该作者
楼主的机器名恐怕不是localhost吧?
我的centos 4.4在默认状态下安装就不是

[root:/]#uname -a
Linux localhost.localdomain 2.6.9-42.0.3.EL #1 Fri Oct 6 05:59:54 CDT 2006 i686i686 i386 GNU/Linux

论坛徽章:
0
7 [报告]
发表于 2006-12-04 15:24 |只看该作者
机器名?
#hostname
WEB

我在想,是不是我启动MYSQL时使用了,
safe_mysqld --user=mysql -O max_connections=2000 -O max_connect_errors=2000 -O wait_timeout=10 -O key_buffer=32M -O back_log=1000 --port=3306 --basedir=/usr/local/mysql --datadir=/var/lib/mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --socket=/tmp/mysql.sock

会不会有影响?

论坛徽章:
0
8 [报告]
发表于 2006-12-04 15:29 |只看该作者
或者说正确的hosts要如何设置
我现在的是:
# Do not remove the following line, or various programs
# that require network functionality will fail.

127.0.0.1 localhost domain
127.0.0.1 localhost
127.0.0.1 WEB localhost

论坛徽章:
0
9 [报告]
发表于 2006-12-04 19:11 |只看该作者
明白了.
127.0.0.1 localhost localhost.WEB
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP