开发者_运维知识库I'm trying to automatically start mysql 5.5.10 community server (gpl) on my mac pro. I've read several threads on this forum. I'm still baffled, because those threads refer to a file:
/Library/StartupItems/MySQLCOM
I don't seem to have this file or folder.
Can someone please help.
btw, I can start mysql using mysqld...and it works fine.
Thanks in advance!
You actuall have to create this file... Best way is with a symlink:
mkdir /Library/StartupItems/MySQLCOM
cd /Library/StartupItems/MySQLCOM/
ln -s /path/to/installation/mysql/support-files/mysql.server MySQLCOM
However I wouldnt recommend this. You should do it proper and use launchd
instead - this is the proper OS X way :-)
First create a plist at /Library/LaunchDaemons/com.mysql.mysqld.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>GroupName</key>
<string>_mysql</string>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>Program</key>
<string>/usr/local/mysql/bin/mysqld</string>
<key>ProgramArguments</key>
<array>
<string>--user=_mysql</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>Umask</key>
<integer>7</integer>
<key>UserName</key>
<string>_mysql</string>
<key>WorkingDirectory</key>
<string>INSTALL_PATH/mysql</string>
</dict>
</plist>
Then an adjust the permission:
sudo chown root /Library/LaunchDaemons/com.mysql.mysqld.plist
sudo chgrp wheel /Library/LaunchDaemons/com.mysql.mysqld.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysqld.plist
Now MySQL should be launched on startup. To test that everything works without rebooting you can run: sudo launchctl load com.mysql.mysqld.plist
then check your error logs for messages.
IF you need to add special args (like custom logs, cnf, etc..) you can do so by specifying them as <string>
elements in the <array>
element following <key>ProgramArguments</key>
. The values of those <string>
element should be the standard switches you would use with mysqld
.
A slight change to how to install the plist for newer versions of OSX.
Instead of simply creating the file in the LaunchDemons folder and modifying permissions, create the plist file in a local folder and then run: sudo install com.mysql.mysqld.plist /Library/LaunchDaemons
精彩评论