-3

I get a can't connect through this socket once per day.

Is this datadir correct?:

[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock

Aborted connection 1270592 to db: 'leechprotect' user: 'leechprotect' host: 'localhost' (Got timeout reading communication packets)


PHP Warning:  mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (11) in wp-includes/wp-db.php on line 1037 

QUESTION: How to change the sql connect from "localhost" to 127.0.0.1 as recommended by many people online. Do I have to do that via bind-address?

mashup
  • 330
  • 1
  • 14
  • 2
    Does the 'outage' happen at the same time each day? Perhaps when a backup is run, logs are rotated or some other scheduled task is being executed? If so, then disable that task. – Zoredache Aug 06 '11 at 04:09
  • 2
    What's the justification behind trying to change to 127.0.0.1? I can't imagine a situation where that would help you connect to the socket. – Shane Madden Aug 06 '11 at 04:15
  • Thanks Shane, that's true. The only problem is that right now I'm pretty clueless why I get that error that Mysql cant connect to the socket. – mashup Aug 06 '11 at 05:44

2 Answers2

0

Find your PHP db config file and change $host from 'localhost' to 'localhost:/var/lib/mysql/mysql.sock'.

quanta
  • 51,413
  • 19
  • 159
  • 217
0

1) If the error always happens at the same time, see which cron jobs run at that time. Cron configuration files (crotabs) are /etc/crontab and /var/spool/cron/*; see man crontab for their format description.

2) Check MySQL error log (in Linux, it's typically /var/lib/mysql/*.err ) for anything that happens around the moment the error occurs.

ivan_pozdeev
  • 352
  • 4
  • 13