PHP 5.3.0 连接mysqli出错的解决

近日因公司开发需要,在本机Win7下架设了Apache+MySql+PHP

所使用PHP版本:PHP5.3.0, 之后发现无法连接mysql数据库,均报超时错误:

PHP Warning: mysqli::mysqli(): [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in xxx.php on line x

PHP Warning: mysqli::mysqli(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
in xxx.php on line x

在网站上查找了很久,均没有有效的解决办法.

后来在国外的网上查到此原因与windows的hosts文件有关

对如下进行修改:

# 127.0.0.1 localhost

#:: 1 localhost

修改为

127.0.0.1 localhost

#:: localhost

问题解决

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值