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.
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:
And ‘mysql’ directory alias is also create at the same location
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
Now we need to migrate the old databases with new databases.
The key directory from the previous instance to be copy is :
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
And If you get errors on the first run, run the command again
sudo /usr/local/mysql/support-files/mysql.server restart
Check the Version
Set MySQL Password
/usr/local/mysql/bin/mysqladmin -u root password ‘yourpasswordhere’
In the latest version of MySQL 5.6 there is a default ‘my.cnf’ file that the database references that is now stored in:
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.