OSX mountain loin
MAC Uncategorized

Upgrade MySQL from 5.5 to 5.6 on OSX Mountain Lion

Today blog is about Upgrade MySQL Database from 5.5 to 5.6 on OSX 10.8 Mountain Lion. Apple and Oracle are in different markets and are not competitors in any aspect. As far as I know, they are each big customers of the other.

I don’t know if macOS is really the right platform for this kind of activity anymore. If you really, really want to run a service locally like this, I recommend Docker instead. Then you can run MySQL under Linux right on your Mac. Docker is more friendly to local CPU and disk resources than a VM.

Taking it a bit further, you might want to consider cloud services. They have definitely reached commodity level now. Prices for services on the research and development scale are very reasonable, if not flat-out free. The cloud providers plan to make money when you deploy. Unless you plan on doing development on a week-long train trip without internet, there is little reason to have local services anymore.

MySQL version 5.6.14 is available for download for OSX, click and install is available named Mac OS X ver. 10.7 (x86, 64-bit), DMG Archive.

First you need to stop the mysql server by running the following command:

sudo /usr/local/mysql/support-files/mysql.server stop

Download the DMG

You need to install all the three installers.

Control/Right click the mysql-5.6…pkg to avoid the security GateKeeper. Follow the installation processes.

Location of MySQL 5.6 Data

So mySQL and files will stored at:

/usr/local/mysql-5.6.14-osx10.7-x86_64

And ‘mysql’ directory alias is also create at the same location

/usr/local/mysql

This point to:

mysql -> mysql-5.6.14-osx10.7-x86_64

And your previous installation is maintained and filed in the same location with the appropriate version you are using

/usr/local/mysql-5.5.13-osx10.6-x86_6

Now we need to migrate the old databases with new databases.

Migrate databases

The key directory from the previous instance to be copy is :

/usr/local/mysql-5.5.13-osx10.6-x86_64/data

So in this instance the previous mysql version was 5.5.13 – rename the new data directory and copy in the old one and fix file ownership to MySQL:

So Change Name of newer data directory

sudo mv /usr/local/mysql-5.6.14-osx10.7-x86_64/data /usr/local/mysql-5.6.14-osx10.7-x86_64/dataold

And Copy Old Databases into new location

sudo cp -rf /usr/local/mysql-5.5.13-osx10.6-x86_64/data /usr/local/mysql-5.6.14-osx10.7-x86_64/

Set Correct Ownership to MySQL

sudo chown -R _mysql /usr/local/mysql-5.6.14-osx10.7-x86_64/data

Start Mysql and repair it

Now we need to start the MySQL database and run a repair/upgrade tool on the older databases

sudo /usr/local/mysql/support-files/mysql.server start

Run the Upgrade Tool

/usr/local/mysql/bin/mysql_upgrade

And If you get errors on the first run, run the command again

Restart MySQL

sudo /usr/local/mysql/support-files/mysql.server restart

Check the Version

/usr/local/mysql/bin/mysql

Set MySQL Password

/usr/local/mysql/bin/mysqladmin -u root password ‘yourpasswordhere’

my.cnf

In the latest version of MySQL 5.6 there is a default ‘my.cnf’ file that the database references that is now stored in:

/usr/local/mysql-5.6.14-osx10.7-x86_64/my.cnf

So if you have made any customisations to the behaviour of MySQL then these will now need to be added in the new my.cnf file and make a copy to /etc so any global changes will be read in when MySQL is launched.

And I hope the solution Upgrade MySQL Database from 5.5 to 5.6 on OSX 10.8 Mountain Lion will work. Please comment below for better information and questions.

Leave a Reply

Your email address will not be published. Required fields are marked *