Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.2Mb
PDF (A4) - 37.2Mb
PDF (RPM) - 36.6Mb
HTML Download (TGZ) - 10.1Mb
HTML Download (Zip) - 10.2Mb
HTML Download (RPM) - 8.8Mb
Man Pages (TGZ) - 206.0Kb
Man Pages (Zip) - 313.0Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  /  ...  /  General Notes on Installing MySQL on OS X

2.4.1 General Notes on Installing MySQL on OS X

You should keep the following issues and notes in mind:

  • As of MySQL server 5.7.8, the DMG bundles a launchd daemon instead of the deprecated startup item. Startup items do not function as of OS X 10.10 (Yosemite), so using launchd is preferred. The available MySQL preference pane under OS X System Preferences was also updated to use launchd.

  • You may need (or want) to create a specific mysql user to own the MySQL directory and data. You can do this through the Directory Utility, and the mysql user should already exist. For use in single user mode, an entry for _mysql (note the underscore prefix) should already exist within the system /etc/passwd file.

  • Because the MySQL package installer installs the MySQL contents into a version and platform specific directory, you can use this to upgrade and migrate your database between versions. You will need to either copy the data directory from the old version to the new version, or alternatively specify an alternative datadir value to set location of the data directory. By default, the MySQL directories are installed under /usr/local/.

  • You might want to add aliases to your shell's resource file to make it easier to access commonly used programs such as mysql and mysqladmin from the command line. The syntax for bash is:

    alias mysql=/usr/local/mysql/bin/mysql
    alias mysqladmin=/usr/local/mysql/bin/mysqladmin
    

    For tcsh, use:

    alias mysql /usr/local/mysql/bin/mysql
    alias mysqladmin /usr/local/mysql/bin/mysqladmin
    

    Even better, add /usr/local/mysql/bin to your PATH environment variable. You can do this by modifying the appropriate startup file for your shell. For more information, see Section 5.2.1, “Invoking MySQL Programs”.

  • After you have copied over the MySQL database files from the previous installation and have successfully started the new server, you should consider removing the old installation files to save disk space. Additionally, you should also remove older versions of the Package Receipt directories located in /Library/Receipts/mysql-VERSION.pkg.

  • Prior to OS X 10.7, MySQL server was bundled with OS X Server.


User Comments
  Posted by Jay Lawrence on February 22, 2016
To make future upgrades easier here is what I do:

1 - place my 'my.cnf' file in /etc/mysql

mkdir /etc/mysql
cp /usr/local/mysql/etc/my.cnf /etc/mysql

Note that the cnf search path is: /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

2 - data in /usr/local/var/mysql/data

Stop MySQL

Edit the my.cnf file and within the [mysqld] section place:
datadir = /usr/local/var/mysql/data

mkdir /usr/local/var
mkdir /usr/local/var/mysql
mv /usr/local/mysql/data /usr/local/var/mysql

3 - Update Launch Daemon values

sudo vi /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

Look for:

<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>

And change to (put var/ in front of mysql/data in lines below)

<string>/usr/local/mysql/bin/mysqld</string>
<string>--user=_mysql</string>
<string>--basedir=/usr/local/mysql</string>
<string>--datadir=/usr/local/var/mysql/data</string>
<string>--plugin-dir=/usr/local/mysql/lib/plugin</string>
<string>--log-error=/usr/local/var/mysql/data/mysqld.local.err</string>
<string>--pid-file=/usr/local/var/mysql/data/mysqld.local.pid</string>

Then when you go to upgrade your my.cnf is retained as are your data directories.
Sign Up Login You must be logged in to post a comment.