Mysql is automatically started when MySQL is started under ubuntulinux _ mysql

Source: Internet
Author: User
Tags arabic numbers
Ubuntu is automatically started when mysql is started under ubuntulinux.

BitsCN.com

Mysql comes with a very useful script for managing mysql services. The default path is $ MYSQL_HOME/support-files. the file name is mysql. server. $ MYSQL_HOME is the installation root directory of mysql. Mysql. server Usage:./mysql. server

1. Pre-enable mysql to start automatically. First, you must register mysql as a service under ubuntu.

Directly copy the mysql. server file to the/etc/init. d/directory.

Sudo cp $ MYSQL_HOME/support-files/mysql. server/etc/init. d/mysql. server

Sudo chmod + x/etc/init. d/mysql. server

2. modify my. cnf to specify the mysql startup user.

Definition: Command 1 = "./mysql. server start-user = user1", Command 2 = "./mysql. server start ". (Note: the difference between commands 1 and 2 lies in the red part)

During mysql compilation and installation, if the "-user = user1" parameter is specified when the configure command is executed, mysql will be started by user1. the server file contains a line like "user = user1" to specify the mysql startup user, but the user specified for this row does not take effect. That is, you need to use Command 1 to start mysql, and Command 2 to start failed.

In order for Command 2 to take effect, and for mysql to start automatically, you need to modify my. cnf and add a line like "user = user1" under the [mysqld] block. In this way, you can use Command 2 to start mysql. mysql can also be started automatically after it is started.

3. set mysql to start automatically

Start mysql on your own

1. $ sudo update-rc.d-f mysql. server defaults

Root @ leroy-linux:/etc/init. d # update-rc.d-f mysql. server defaults

Adding system startup for/etc/init. d/mysql...

/Etc/rc0.d/K20mysql. server->.../init. d/mysql. server

/Etc/rc1.d/K20mysql. server->.../init. d/mysql. server

/Etc/rc6.d/K20mysql. server->.../init. d/mysql. server

/Etc/rc2.d/S20mysql. server->.../init. d/mysql. server

/Etc/rc3.d/S20mysql. server->.../init. d/mysql. server

/Etc/rc4.d/S20mysql. server->.../init. d/mysql. server

/Etc/rc5.d/S20mysql. server->.../init. d/mysql. server

If you do not want mysql to start on your own, you can use

1. $ sudo update-rc.d-f mysql. server remove

Root @ sean-linux:/etc/init. d # update-rc.d-f mysql remove

Removing any system startup links for/etc/init. d/mysql...

/Etc/rc0.d/K21mysql. server

/Etc/rc1.d/K21mysql. server

/Etc/rc2.d/S19mysql. server

/Etc/rc3.d/S19mysql. server

/Etc/rc4.d/S19mysql. server

/Etc/rc5.d/S19mysql. server

/Etc/rc6.d/K21mysql. server

4. service usage

Start mysql: service mysql. server start;

Stop mysql: service mysql. server stop;

View the mysql running status: service mysql. server status.

In addition, make sure that mysql User user1 has read and write permissions on $ MYSQL_HOME. otherwise, mysql cannot be started due to permission issues.

Supplement

Ubuntu unactivates Apache and MySQL

1. install sysv-conf-rc

2. sudo update-rc.d-f mysql remove services started by mysql random

Sudo update-rc.d-f apache2 remove services started by apache2

3. check the apache and mysql startup scripts in/etc/rc2.d/. Generally, they are two Arabic numbers followed by an English letter and the script name. If the English letter is S, it will start automatically, and if the English letter is K, the opposite is true. Therefore, you only need to find the apache and mysql startup scripts and change S to K.

BitsCN.com

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.