Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
12.0k views
in Technique[技术] by (71.8m points)

php - Warning: mysql_connect(): Can't connect to local MySQL server

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?????

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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. As well my wild guess, go through your code and check you always get your connection close right and all your queries as well.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...