配置MySQL服務的自啟動

來源:互聯網
上載者:User

[root@Oracle9i mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@oracle9i mysql]# chmod +x /etc/init.d/mysql
[root@oracle9i etc]# chkconfig --list mysql
service mysql supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add mysql')
[root@oracle9i etc]# chkconfig --add mysql 345 on
chkconfig version 1.3.13.5.EL4 - Copyright (C) 1997-2000 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.

usage:   chkconfig --list [name]
         chkconfig --add <name>
         chkconfig --del <name>
         chkconfig [--level <levels>] <name> <on|off|reset>
[root@oracle9i etc]# chkconfig --add mysql
[root@oracle9i etc]# chkconfig --list mysql
mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off

重啟機器,測試:
[root@oracle9i mysql]# reboot

Broadcast message from root (pts/1) (Wed Mar  2 15:44:42 2011):

The system is going down for reboot NOW!

重啟後,發現mysql資料庫已經自動啟動起來
[root@oracle9i ~]# ps -ef | grep mysql
root      5508     1  0 15:46 ?        00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/oracle9i.pid
mysql     5761  5508  0 15:46 ?        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=mysql --log-error=/usr/local/mysql/data/oracle9i.err --pid-file=/usr/local/mysql/data/oracle9i.pid --socket=/tmp/mysql.sock --port=3306
root      6749  6716  0 15:47 pts/0    00:00:00 grep mysql
[root@oracle9i ~]# mysql -e "select host from db" mysql
+------+
| host |
+------+
| %    |
| %    |
+------+
[root@oracle9i ~]# mysql -e "show database" mysql
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
[root@oracle9i ~]# mysql -e "select host,db,user from db" mysql
+------+---------+------+
| host | db      | user |
+------+---------+------+
| %    | test    |      |
| %    | test\_% |      |
+------+---------+------+

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.