Add MySQL as a system service in CentOS7

Source: Internet
Author: User

If you are installing MySQL through the tar package, it is not automatically added to the system service and can be added by yourself in the following way.

Add Mysql.service to the/usr/lib/systemd/system directory as follows:

[Unit]description=mysqlafter=syslog.target network.target remote-fs.target nss-  Lookup.target[service]type=forkingpidfile=/usr/local/mysql/data/xxx. Pidexecstart=/usr/ local/mysql/support-files/mysql.server startexecreload=/bin/kill -s HUP $MAINPIDExecStop =/bin/Kill -s QUIT $MAINPIDPrivateTmp=false[Install]

Reload the unit, scan for new or changed cells, and make the newly added mysql.service effective

Systemctl Daemon-reload

After that, you can use the following command to manipulate MySQL

Systemctl Enable Mysqlsystemctl start mysqlsystemctl stop mysqlsystemctl restart MySQL

The above four commands are:

    1. Set to boot
    2. Start
    3. Stop it
    4. Restart

Add MySQL as a system service in CentOS7

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.