3

I have seen numerous suggestions about using MAMP to install MySQL on OS X, but since I have the Server app and already have Apache and PHP, which I do not wish to mess up, I wonder how to properly install MySQL.

THIS WORKS
Using the community download's DMG installer package from the MySQL website it has two flaws:

  1. The page states its latest version to be OS X 10.9
  2. Once the installer is downloaded and mounted, it displays that it is actually meant for OS X 10.8 (verified with the OS X 10.8 download, which is identical in size; they just changed the name of the DMG, which is pretty lame, but a story for itself)

Trying to install MySQL from that package nevertheless, it ran without problems. I can even manually start the MySQL server, which, according to System Preferences, is then running.

THIS DOES NOT WORK
However, the next parts do not work and I wonder how to actually get them working:

  • /usr/local/mysql-5.6.25-osx10.8-x86_64/bin/ has not been added to the path, which makes running mysql a pain (sure I can manually add it, but if the installer failed to do so, something is not right from the start)
  • using System Preferences to get the MySQL Server to start on system start failed with a less than informative error message

MySQL Server Error Message

  • even Console is disappointingly sparse on information and just shows the following two lines when trying to tick the checkbox

    7/21/2015 8:18:54.748 PM System Preferences[5620]: about to perform command
    7/21/2015 8:18:54.764 PM System Preferences[5620]: status= 4
    

You may wonder why install MySQL when you have Postgres. Well, I want to install MediaWiki and do not want to mess around with the system accounts, like resetting passwords (it may break every other Server service which uses Postgres) and secondly, following the installation, MediaWiki prefers MySQL over Postgres (which I second as well).

Did anyone successfully install MySQL on their OS X Yosemite installation (running OS X Server)?

4 Answers 4

2

Preface:

It's no problem to install MAMP, MAMP Pro or Bitnami MAMP Stack on OS X Server (Yosemite or older). All of them are self-containing stacks and get installed to the /Applications folder. They don't interfere with any original software like Oracle MySQL/PostgreSQL/OS X Server postgres provided you don't use their distinctive ports. All the MAMP stacks are easy to configure to reserve other ports (e.g. mysql/http/https etc).

It's not advised to use the OS X Server PostgreSQL for any of your purposes. It may be unnoticed subject of change by Apple. Download and install PostgreSQL and use that one.

Installing Oracle MySQL Community Edition:

Trying to set-up and get EJBCA working on Yosemite I had to install Oracle MySQL recently and it worked flawlessly.

After downloading the installer, open the image and install MySQL with the default settings using your admin account.

The default settings meanwhile install a plist to /Library/LaunchDaemons to provide the recommended way to start-up services at boot time (with launchd). Older versions used to use the /Library/StartupItems folder.

A proper com.oracle.oss.mysql.mysqld.plist file in /Library/LaunchDaemons looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>             <string>com.oracle.oss.mysql.mysqld</string>
    <key>ProcessType</key>       <string>Interactive</string>
    <key>Disabled</key>          <false/>
    <key>RunAtLoad</key>         <true/>
    <key>KeepAlive</key>         <true/>
    <key>SessionCreate</key>     <true/>
    <key>LaunchOnlyOnce</key>    <false/>
    <key>UserName</key>          <string>_mysql</string>
    <key>GroupName</key>         <string>_mysql</string>
    <key>ExitTimeOut</key>       <integer>600</integer>
    <key>Program</key>           <string>/usr/local/mysql/bin/mysqld</string>
    <key>ProgramArguments</key>
        <array>
            <string>/usr/local/mysql/bin/mysqld</string>
            <string>--user=_mysql</string>
            <string>--basedir=/usr/local/mysql</string>
            <string>--datadir=/usr/local/mysql/data</string>
            <string>--plugin-dir=/usr/local/mysql/lib/plugin</string>
            <string>--log-error=/usr/local/mysql/data/mysqld.local.err</string>
            <string>--pid-file=/usr/local/mysql/data/mysqld.local.pid</string>
            <string>--port=3307</string>
        </array>
    <key>WorkingDirectory</key>  <string>/usr/local/mysql</string>
</dict>
</plist>

Until now I never had a problem to get this running right out-of-the-box. If your MySQL doesn't start properly please check the /Library/LaunchDaemon and the /Library/StartupItems folder for older versions of the plist or conflicting start-up-items.

The only thing indeed you have to do manually, is adding the bin folder of mysql to your path.

You have the following options:

  • add it to /etc/paths to add it to all paths of your users with:

    sudo echo "/usr/local/mysql/bin" >> /etc/paths
    
  • add it to your user's path by e.g.:

    touch ~/.bash_profile
    echo "export PATH=/usr/local/mysql/bin:$PATH" >> ~/.bash_profile
    

    /usr/local/mysql/bin instead of /usr/local/mysql-5.6.25-osx10.8-x86_64/bin works even after future updates because a link called mysql is created while installation of MySQL linking to the real mysql-version-osversion-proc_bit folder.

  • use launchd (question & answer here - you may find some other methods there also)

If you prefer to use a GUI to configure, tweak and work with MySQL, download MySQL Workbench. Please consider to use port 3307 instead of 3306 connecting from your local host to localhost. You may set the root password after connecting the first time.

1
  • Finally got to test your detailed instructions. While it may be ok to use MAMP, a good system is a clean system and for OS X Server I have yet to see why it is required when having all the tools already (except MySQL). Using the download link you provided, installed it again and it worked this time. Found some MySQL stuff in the StartupItems, which I removed beforehand. For the path, /private/etc also holds a directory named path.d, which I used to add a new file with the path. Better than writing into a system file. MediaWiki is still not working though, getting a connection error.
    – Phoenix
    Commented Sep 26, 2015 at 22:54
3

I found the homebrew version of mysql worked perfectly on OS X 10.10.3 and 10.10. running Server. brew install mysql and all was good - mysql.server start starts it and mysql.server stop does the reverse.

0

For what it's worth, I have OSX 10.10.4 and my installation of MySQL 5.6.26 for OSX 10.9 worked fine and I can start/stop it successfully through System Preferences. What didn't work well: the default connection method is to localhost via socket and all attempts to enable connections via TCP to 127.0.0.1 proved futile.

1
  • What did you use for installation? Commented Nov 18, 2015 at 5:32
0

Depending on your needs, it might be fine to just install it in a headless virtual box that's set to autostart at boot. It gives you the option of running an actual LAMP stack with minimal overhead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .