Mysql 5.5.10 - Mac 10.6.x - auto start

后端 未结 2 2042
小蘑菇
小蘑菇 2021-01-06 21:38

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 r

相关标签:
2条回答
  • 2021-01-06 22:01

    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

    0 讨论(0)
  • 2021-01-06 22:13

    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.

    0 讨论(0)
提交回复
热议问题