--- /etc/init.d/mysql 2008-11-14 18:05:52.000000000 +0100 +++ /etc/init.d/mysql_fixed 2009-11-16 16:01:39.904422000 +0100 @@ -104,7 +104,7 @@ else /usr/bin/mysqld_safe > /dev/null 2>&1 & # 6s was reported in #352070 to be too few when using ndbcluster - for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do + for i in `seq 1 14`; do sleep 1 if mysqld_status check_alive nowarn ; then break; fi log_progress_msg "." @@ -134,32 +134,25 @@ # at least for cron, we can rely on it here, too. (although we have # to specify it explicit as e.g. sudo environments points to the normal # users home and not /root) - log_daemon_msg "Stopping MySQL database server" "mysqld" + if mysqld_status check_dead nowarn; then + log_daemon_msg "MySQL database server is not running." + exit 0 + fi + + log_daemon_msg "Shutting MySQL database server down..." if ! mysqld_status check_dead nowarn; then set +e - shutdown_out=`$MYADMIN shutdown 2>&1`; r=$? + $MYADMIN shutdown 2>&1 >/dev/null; + for i in `seq 1 5`; do + sleep 1; if mysqld_status check_dead nowarn; then log_daemon_msg "Shutdown complete."; break; fi + done set -e - if [ "$r" -ne 0 ]; then - log_end_msg 1 - [ "$VERBOSE" != "no" ] && log_failure_msg "Error: $shutdown_out" - log_daemon_msg "Killing MySQL database server by signal" "mysqld" - killall -15 mysqld - server_down= - for i in 1 2 3 4 5 6 7 8 9 10; do - sleep 1 - if mysqld_status check_dead nowarn; then server_down=1; break; fi - done - if test -z "$server_down"; then killall -9 mysqld; fi - fi - fi - - if ! mysqld_status check_dead warn; then - log_end_msg 1 - log_failure_msg "Please stop MySQL manually and read /usr/share/doc/mysql-server-5.0/README.Debian.gz!" - exit -1 - else - log_end_msg 0 - fi + if ! mysqld_status check_dead warn; then + log_failure_msg "MySQL did not respond anymore, killed with signal -9. Please check the error log." + killall -9 mysqld 2>/dev/null + exit 1 + fi + fi ;; 'restart')