積丹尼 Dan Jacobson wrote: > Please try the following experiment: > # /etc/init.d/mysql start > [ ok ] Starting MySQL database server: mysqld . . .. > [info] Checking for tables which need an upgrade, are corrupt or were > not closed cleanly.. > # /etc/init.d/mysql stop > [....] Stopping MySQL database server: mysqldERROR 2002 (HY000): Can't > connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) > ERROR 2002 (HY000): Can't connect to local MySQL server through socket > '/var/run/mysqld/mysqld.sock' (2) > ERROR 2002 (HY000): Can't connect to local MySQL server through socket > '/var/run/mysqld/mysqld.sock' (2) > ERROR 2002 (HY000): Can't connect to l... > . ok
It is a race condition that has been exposed. At the termination of the start script the mysql daemon is not quite yet ready for operation. It apparently takes another moment for the daemon to finish getting ready to go. > The workaround it to issue at least one connection even if very brief, > # mysql --user=root --password=... > ... > between the start and stop. This seems to have nothing to do with with the command between. It is only with giving the server a little more time to start up. Running that command between simply allows startup to fully complete. If you wait a little between you will always avoid the problem too. On my particular speed of machine if I sleep a few seconds between then the problem is always avoided. service mysql start ; sleep 5 ; service mysql stop Interestingly I can recreate the problem trivially with: service mysql start ; service mysql stop But when restarting I never see the problem. service mysql restart This seems an extremely minor bug. It is only seen if you start mysql and then immediately try to stop it. That is not a normal operating action for the daemon. Normally you will start the daemon and then make use of it. Bob
signature.asc
Description: Digital signature