错误Can't connect to MySQL server on 'localhost' (10061)

81 views
Skip to first unread message

狗尾草

unread,
Oct 27, 2011, 1:04:58 PM10/27/11
to imy...@googlegroups.com
请教下大家,windows服务器,apache web服务器,mysql5.2,常常爆出连接错误。有什么好办法能定位错误?
我知道windows服务器比较让人讨厌,朋友那暂时还不能换。

Fatal error: Uncaught exception 'Exception' with message 'Connect failed: Can't connect to MySQL server on 'localhost' (10061)' in D:\wwwroot\include\library\DB.class.php:46 Stack trace: #0 D:\wwwroot\include\library\DB.class.php(22): DB->__construct() #1 D:\wwwroot\include\library\DB.class.php(81): DB::Instance() #2 D:\wwwroot\include\library\DB.class.php(417): DB::EscapeString('city') #3 D:\wwwroot\include\library\DB.class.php(153): DB::BuildCondition(Array) #4 D:\wwwroot\include\function\common.php(657): DB::LimitQuery('category', Array) #5 D:\wwwroot\include\function\common.php(643): option_category('city', false, true) #6 D:\wwwroot\app.php(33): option_hotcategory('city', false, true) #7 D:\wwwroot\index.php(2): require_once('D:\wwwroot\app....') #8 {main} thrown in D:\wwwroot\include\library\DB.class.php on line 46


--
Best regards,
Hunk Guo
--

Yan Wang

unread,
Oct 28, 2011, 1:52:41 AM10/28/11
to imy...@googlegroups.com
1、文件里配置的账户信息是否正确,在出问题时,用文件里写的mysql帐号登录mysql -hlocalhost,看看是否可以登录。
2、windows网路服务?防火墙?

> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的"[MySQL中文用户群]"论坛。
> 要向此网上论坛发帖,请发送电子邮件至 imy...@googlegroups.com
> 要取消订阅此网上论坛,请发送电子邮件至 imysql+un...@googlegroups.com
> 若有更多问题,请通过 http://groups.google.com/group/imysql?hl=zh-CN 访问此网上论坛。
>

狗尾草

unread,
Oct 28, 2011, 10:00:17 PM10/28/11
to imy...@googlegroups.com
1.从我监控的情况看,mysql连接数及流量一直正常,下次我会试试是否是Mysql挂掉了。
2.是安装的windows服务,防火墙没做限制。另外本地php程序连接的就是本机的mysql.

我现在有个不好的猜测,怀疑是windows对PHP或mysql有某种限制,只是没公开而已。

--
Best regards,
Hunk Guo
--



2011/10/28 Yan Wang <yanwa...@gmail.com>

Fwolf

unread,
Oct 27, 2011, 10:03:27 PM10/27/11
to imy...@googlegroups.com
像是服务没有起来,手工连接下试试,
另外看看 mysql 的日志。
服务器地址改成 127.0.0.1 试试。

> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的“[MySQL中文用户群]”论坛。
> 要向此网上论坛发帖,请发送电子邮件至 imy...@googlegroups.com
> 要取消订阅此网上论坛,请发送电子邮件至 imysql+un...@googlegroups.com
> 若有更多问题,请通过 http://groups.google.com/group/imysql?hl=zh-CN 访问此网上
> 论坛。

--
http://www.fwolf.com/
Bash: 从字符串的开始抹去最短的匹配子串,可以用?/*代表一个/多个任意字符:
$ echo ${PWD#/??}

signature.asc

napoleonu

unread,
Oct 30, 2011, 10:22:31 PM10/30/11
to imy...@googlegroups.com
这个是团购开源程序最土的报错 http://www.zuitu.com/download.html ,把localhost改成127.0.0.1不知道怎么样。

2011/10/28 Fwolf <fwo...@gmail.com>

yuwenbao liu

unread,
Oct 30, 2011, 10:57:12 PM10/30/11
to imy...@googlegroups.com
看下mysql 的err日志,另外可以用crontab在提示报错的那个时间段内不断telnet mysql端口或者查看mysql进程是否有问题

2011/10/31 napoleonu <napo...@gmail.com>

Fwolf

unread,
Oct 31, 2011, 5:03:31 AM10/31/11
to imy...@googlegroups.com
shell 下连接 mysql 看通否,
通的话就去查 php 那头。

On Mon, Oct 31, 2011 at 10:22:31AM +0800, napoleonu wrote:
> 这个是团购开源程序最土的报错 http://www.zuitu.com/download.html ,把localhost改
> 成127.0.0.1不知道怎么样。
>

--
http://www.fwolf.com/
你的history(命令历史)中频率最高的指令:
$ history|awk '{a[$2]++} END{for(i in a){printf "%5d\t%s\n",a[i],i}}'|sort -rn|head
- http://www.yining.org/2008/04/13/whats-in-my-history/

signature.asc

jianli yang

unread,
Dec 4, 2011, 8:39:19 PM12/4/11
to imy...@googlegroups.com
必须绑定地址, bind-address 这个需要设置

在 2011年10月28日 上午1:04,狗尾草 <guo...@gmail.com>写道:

zhanjiang an

unread,
Dec 8, 2011, 11:26:38 PM12/8/11
to imy...@googlegroups.com
你确认你Mysql的连接参数设置了?使用连接池的话,默认情况下,某连接不使用的话,一段时间之后会自动断开。
Reply all
Reply to author
Forward
0 new messages