解決方法:
修改/etc/init.d/MySQLd.
在mysql裡創建dameon用戶,然後再修改/etc/init.d/MySQLd.
具體操作如下:
我們不妨先看看/etc/init.d/MySQLd起動腳本是如何工作的,注意下面的一段
# If you've removed anonymous users, this line must be changed to
# use a user that is allowed to ping MySQLd.
ping="/usr/bin/mysqladmin -uUNKNOWN_MySQL_USER ping"
# Spin for a maximum of ten seconds waiting for the server to come up
if [ $ret -eq 0 ]; then
for x in 1 2 3 4 5 6 7 8 9 10; do
if [ -n "`$ping 2> /dev/null`" ]; then
break;
else
sleep 1;
fi
done
if !([ -n "`$ping 2> /dev/null`" ]); then
echo "Timeout error occurred trying to start MySQL
Daemon." action $"Starting $prog: " /bin/false
else
action $"Starting $prog: " /bin/true
fi
else
action $"Starting $prog: " /bin/false
fi
[ $ret -eq 0 ] && touch /var/lock/subsys/MySQLd
return $ret
我們看到,腳本判斷mysql是否起動,使用的是MySQLadmin ping命令. http://webjx.com
而這個命令想要正確執行是需要能夠登錄mysql的.現在一些默認帳號已經刪除,而且其它帳號已經設置了密碼(默認沒有設置密碼).於是它沒有辦法連接到MySQL. http://webjx.com
於是我用了下面的辦法解決.
a)建立一個帳號,不設置密碼,不給任何權限.
b)修改/etc/init.d/MySQLd
下面我給出具體操作
#MySQL -u root -p passwd
MySQL>GRANT select ON test.* TO daemon@localhost
MySQL>revoke select on test.* from daemon@localhost
vi打開/etc/init.d/MySQLd
把下面這行
ping="/usr/bin/mysqladmin -uUNKNOWN_MySQL_USER ping"
修改為
ping="/usr/bin/MySQLadmin -udaemon ping"
保存,退出.
重新起動MySQL
#/etc/init.d/MySQLd restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
這樣就可以了.