Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to upgrade the MySQL in MAMP to MySQL 5.7?

Tags:

mysql

macos

mamp

Is it possible to upgrade the MAMP MySQL library to 5.7? I am currently running 5.6 (which I upgraded to using MAMP’s upgrade script ) Or would I need to install MySQL natively on my system? (macOS 10.11 El Capitan)

If someone could point me in the right direction… Thanks!

like image 589
harveyslash Avatar asked Mar 15 '16 00:03

harveyslash


2 Answers

Upgrade MAMP to Mysql 5.7

#!/bin/sh

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.10-osx10.10-x86_64.tar.gz
tar xfvz mysql-5.7*

echo "stopping mamp"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld

echo "creating backup"
sudo rsync -arv --progress /Applications/MAMP ~/Desktop/MAMP-Backup

echo "copy bin"
sudo rsync -arv --progress mysql-5.7.*/bin/* /Applications/MAMP/Library/bin/ --exclude=mysqld_multi --exclude=mysqld_safe 

echo "copy share"
sudo rsync -arv --progress mysql-5.7.*/share/* /Applications/MAMP/Library/share/

echo "fixing access (workaround)"
sudo chmod -R o+rw  /Applications/MAMP/db/mysql/
sudo chmod -R o+rw  /Applications/MAMP/tmp/mysql/
sudo chmod -R o+rw  "/Library/Application Support/appsolute/MAMP PRO/db/mysql/"

echo "starting mamp"
sudo /Applications/MAMP/bin/start.sh

echo "migrate to new version"
/Applications/MAMP/Library/bin/mysql_upgrade -u root --password=root -h 127.0.0.1
like image 127
Jaya Konduru Avatar answered Oct 10 '22 17:10

Jaya Konduru


UPDATE: Version 5.0 of MAMP now includes MySQL 5.7 already in the installer! Just upgrade your core MAMP setup and you are set to go with MySQL instead of having to jump through technical hoops like this.

Leaving answer below as a reference for anyone who needs it.


While I have read this answers and comments here—as well as some similar linked tutorials on GitHub and such—there were a few things that confused me in some of the tutorials. Such as instructions to set chmod -O o+rw and even a comment about creating a symbolic link to /tmp/mysql.sock; why do that when MAMP out of the box should be self contained and not require such changes? So here are the instructions I have put together based on my experience getting MySQL upgraded for MAMP 4.4.1 on mac OS 10.3.4 (High Sierra).

First, get a copy of the macOS binaries for MySQL 5.7; note that as of me posting this answer MySQL 5.7.22 is the current version so adjust this URL to whatever new version you might want to use:

curl -OL https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-macos10.13-x86_64.tar.gz

Decompress it like this:

tar xfvz mysql-5.7*

Copy the bin/ and share/ stuff into MAMP via Rsync like this:

sudo rsync -arv --progress mysql-5.7.*/bin/* /Applications/MAMP/Library/bin/ --exclude=mysqld_multi --exclude=mysqld_safe
sudo rsync -arv --progress mysql-5.7.*/share/* /Applications/MAMP/Library/share/

Copy your existing MySQL 5.6 database directory like this; just note that the mysql56 directory is temporarily needed during the upgrade but can be discarded after the rest of the MySQL 5.7 upgrade is done:

sudo cp -r /Applications/MAMP/db/mysql56 /Applications/MAMP/db/mysql57

Once that is done, get rid of MySQL database specific binaries like this for upgrade:

sudo rm -rf /Applications/MAMP/db/mysql57/mysql/innodb_*
sudo rm -rf /Applications/MAMP/db/mysql57/mysql/slave_*

And instead of changing permissions to o+rw just change the owner of the DB directory to your current user; this matches how MAMP installs this stuff:

sudo chown -R ${USER}:admin /Applications/MAMP/db/mysql57

Now run this Sed command to adjust the mysqld_safe script to point to the new MySQL 5.7 path; you could probably just open this file up in a text editor and change all instances of mysql56 to mysql57as well:

sed -i.bak 's/mysql56/mysql57/g' /Applications/MAMP/Library/bin/mysqld_safe

Finally, if you use MAMP and set a my.cnf file, that should be set in /Applications/MAMP/conf/my.cnf… But by doing this upgrade, the default search path of the my.cnf in MAMP will be /usr/local/mysql/etc/ instead of the expected /Applications/MAMP/conf/ since that is where the new binary expects it to be set. Clearly we’re not going to recompile MySQL at this point so the cleanest/simplest thing to do to make your MAMP setup truly portable again is to change this line in the startMysql.sh from this:

/Applications/MAMP/Library/bin/mysqld_safe --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log &

To this; note we are adding the --defaults-extra-file= option before all the otgers:

/Applications/MAMP/Library/bin/mysqld_safe --defaults-extra-file=/Applications/MAMP/conf/my.cnf --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log &

With all of that command line work done, launch MAMP via the application, start the MySQL and Apache servers and then drop back into the command like to run this command to upgrade the databases:

/Applications/MAMP/Library/bin/mysql_upgrade --user=root --password=root --port=3306 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --force

And finally run this command to get the mysql.sock properly set for MAMP path instead of that /tmp/mysql.sock path:

/Applications/MAMP/Library/bin/mysql_config_editor --verbose set --socket=/Applications/MAMP/tmp/mysql/mysql.sock

When this is all done, and you have confirmed MySQL is running as expected, just toss the old MySQL 5.6 directory like this:

sudo rm -rf /Applications/MAMP/db/mysql56

With all that done you should all be set to cleanly use MySQL 5.7 under MAMP 4.4.1.

like image 27
Giacomo1968 Avatar answered Oct 10 '22 17:10

Giacomo1968