Configure MySQL service auto-start

Source: Internet
Author: 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

Restart the machine and test:
[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!

After the instance is restarted, the mysql database is automatically started.
[Root @ oracle9i ~] # Ps-ef | grep mysql
Root 5508 1 0 :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? 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 -- Ports = 3306
Root 6749 6716 0 00:00:00 pts/0 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 \ _ % |
+ ------ + --------- + ------ +

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.