Start MySQL with launchctl from Mac

Source: Internet
Author: User

Under the Mac installed MySQL, want to set up the boot from start, originally thought and the General Linux system, is also in RC.D such directory placement startup script. On the Internet to check some information, found that Apple should be completely closed, can only use the Mac system Launchctl to do this thing.

Launchctl in fact is to write a *.plist file, its role and Linux in the role of Crontab is the same. The following code is a com.mysql.plist I wrote:

Plist Code

<! DOCTYPE plist public "-//apple//dtd plist 1.0//en" "Http://www.apple.com/DTDs/PropertyList-1.0.dtd" >

<plist version="1.0" >

<dict>

<key>Label</key>

<string>com.mysql</string>

<key>ProgramArguments</key>

<array>

<string>/usr/local/mysql/bin/mysqld_safe</string>

</array>

<key>RunAtLoad</key>

<true/>

<key>KeepAlive</key>

<false/>

</dict>

</plist>

And then put this file under/library/launchdaemons, about this Mac launch directory, there are several, the role of a number of different, there are a lot of introduction on the Internet, here do not repeat said (casually BS, those who copied other articles, never write their own, Copy it to your blog, so that Google, all kinds of links, are the same content).

Finally call the LAUNCHCTL command, load this plist,

SH code
    1. Launchctl load-w Com.mysql.plist

If the command executes without errors, restarting the Mac,mysql is ready to start.

In this process, there are a few points to note, listed below:

1. Dubious ownership on file (skipping) error occurs when executing LAUNCHCTL

The reason is: This plist file must belong to the root user, wheel group, modified with Chown

SH code
    1. sudo chown root:wheel com.mysql.plist

2. When performing Launchctl, Launchctl:no plist was returned this error

The reason is: the contents of the Plist file may be malformed.

Use the following command to see if there is a problem with the file format, I use this check to see that there is a <true> tag is not closed.

SH code
    1. sudo plutil-lint ~/com.mysql.plist

Start MySQL with launchctl from Mac

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.