警告:mysql_connect():无法连接到本地MySQL服务器 [英] Warning: mysql_connect(): Can't connect to local MySQL server

查看:83
本文介绍了警告:mysql_connect():无法连接到本地MySQL服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

警告:mysql_connect():无法通过第2行/home/aa/public_html/bb/db.php中的套接字'/var/lib/mysql/mysql.sock'(11)连接到本地MySQL服务器 无法连接:

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (11) in /home/aa/public_html/bb/db.php on line 2 Could not connect:

可能会收到此错误,但问题是此错误是不定期出现的,有时不是一整天都出现,有时是无数次.

iam getting this error but the problem is that this error comes irregularly,sometimes it didnt come all the day and sometimes it comes countless times.

这可能是什么原因?????

what could be the possible reason for this?????

推荐答案

这可能意味着MYSQL已关闭,或者在连接时使用了错误的主机名.另一个可能的原因可能是php相对于mysql的套接字配置不同,您可以通过查看mysql config中的条目套接字来检入.文件,并查看phpinfo()的输出,您只需要比较它即可.也可能您的计算机上的其他人也使用该套接字.

That could mean that MYSQL is down or you use the wrong host name while connect. One more possible reason for that could be difference in socket configuration of php against mysql, you can check it in by looking at entry socket in mysql config. file and by looking at output of phpinfo(), you need just to compare it. Or it could that someone else on your machine also using that socket.

PS.同样,我很奇怪,请仔细检查您的代码,并检查您是否始终正确关闭连接以及所有查询.

PS. As well my wild guess, go through your code and check you always get your connection close right and all your queries as well.

这篇关于警告:mysql_connect():无法连接到本地MySQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆