Ubuntu下設定MySQL自啟動故障解決一例

來源:互聯網
上載者:User

Ubuntu下設定MySQL自啟動故障解決一例

Ubuntu下解決MySQL自啟動,執行命令:

# chkconfig --list
The program 'chkconfig' is currently not installed.  You can install it by typing:
apt-get install chkconfig

發現沒安裝chkconfig指令碼,安裝它:

root@www.bkjia.com:~# apt-get install chkconfig
Reading package lists... Done
……

安裝後執行:

# chkconfig --list | grep mysql
mysql                    0:off  1:off  2:off  3:off  4:off  5:off  6:off

可見MySQL不是自啟動服務。

用chkconfig讓MySQL自啟動時,執行命令報錯:

# chkconfig -a mysql
/sbin/insserv: No such file or directory
mysql                    0:off  1:off  2:off  3:off  4:off  5:off  6:off

網上提供的解決方案是:

# ln -s /usr/lib/insserv/insserv /sbin/insserv

執行命令,繼續報錯

# chkconfig mysql on
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'mysql' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `mysql'
......

繼續尋找原因,發現是:

chkconfig命令是用於RedHat/Fedora發行版的,而對於像Ubuntu之類的Debian發行版,應該使用這個命令:

sudo update-rc.d mysql defaults

驗證一下:

# chkconfig --list | grep mysql
mysql                    0:off  1:off  2:on  3:on  4:on  5:on  6:off
果然搞定了!

最後提醒一句,別忘了刪除之前建立的符號串連

# rm -f /sbin/insserv 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.