1. 程式人生 > >ubuntu自啟動mysql

ubuntu自啟動mysql

mysql資料在平常的開發中使用的比較平凡,上週客戶機房斷電了,來電後機器自動重啟了,但是我們的mysql沒有自動重啟,導致我們的應用服務不可用,網上也有好多mysql自啟動的例子,今天我就給一個最簡單的例子(root使用者):

1、執行sysv-rc-conf --level 2345 mysql on,如果提示沒有sysv-rc-conf命令,先下載,下載命令:apt-get install sysv-rc-conf

2、檢視服務列表sysv-rc-conf --list mysql,如果看到2345都是on,則設定成功

[email protected]:/home/file# sysv-rc-conf --list mysql
mysql        2:on       3:on    4:on    5:on
[email protected]
:/home/file#

3、重啟reboot,檢驗msyql是否已經重啟,ps -ef|grep mysql,如出現下圖,說明重啟成功

[email protected]:/home/file# ps -ef|grep mysql
root       1700      1  0 11:21 ?        00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/cs2.pid
root       2023   1700  0 11:21 ?        00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=root --log-error=cs2.err --pid-file=/usr/local/mysql/data/cs2.pid --socket=/usr/local/mysql/tmp/mysql.sock --port=3306
root       3121   2602  0 11:27 pts/1    00:00:00 grep --color=auto mysql
[email protected]
:/home/file#