1

I have a mysql database running on a CentOS server. I have noticed that, when left to run for several weeks without restarting the service, then when I need to do a restart (/etc/init.d/mysqld restart), the service will display "fail" for both stop and start. It will then refuse to start again, unless I kill -9 the mysqld_safe and mysqld processes.

Why does this happen and what can I do to prevent it?

Using mysql 5.1.66 on Centos 6.3

RolandoMySQLDBA
  • 182,700
  • 33
  • 317
  • 520
periklis
  • 123
  • 1
  • 6

1 Answers1

3

The script /etc/init.d/mysqld is dependent on the presence of the file mysql.sock. If that file is missing, run service mysqld restart or service mysqld stop simply does not work.

Over the years, I have seen many incidents where mysql.sock just disappears (going back to MySQL 4.x). See ServerFault Post : What should mysqld.sock contain, why don't I have it?. When this happens, you will have to resort to mysqladmin shutdown.

If you tried this:

mysqladmin -h127.0.0.1 -uroot -p shutdown

this may fail if it authenticates as root@localhost

Instead, shutdown mysql using the TCP/IP protocol

mysqladmin -h127.0.0.1 --protocol=tcp -uroot -p shutdown

This bypasses checking for the socket file mysql.sock.

Give it a Try !!!

CAVEAT

I have discussed using mysqladmin shutdown before

RolandoMySQLDBA
  • 182,700
  • 33
  • 317
  • 520
  • Thanks, I'll have to wait for a while so I can try this (freshly restarted instances don't have a problem), I'll post back or accept then. – periklis Feb 28 '13 at 19:00
  • +1 this is were I was going asking for the location of the pid file but I'll bet you're spot on in pointing to the socket file. The file is probably getting removed by tmpwatch http://www.linuxcommand.org/man_pages/tmpwatch8.html which may possibly be configured inside /etc/cron.daily on CentOS. – Michael - sqlbot Feb 28 '13 at 20:17