Skip to content

Instantly share code, notes, and snippets.

@ryantology
Forked from dj1020/migrate.sh
Last active July 18, 2017 03:19
Show Gist options
  • Save ryantology/bc1591699fb8e04219c91601af35d403 to your computer and use it in GitHub Desktop.
Save ryantology/bc1591699fb8e04219c91601af35d403 to your computer and use it in GitHub Desktop.
Upgrade MAMP 4.0 to Mysql 5.7
#!/bin/sh
FILE='mysql-5.7.16-osx10.11-x86_64.tar.gz'
# MySQL direct is typically VERY slow. This uses a mirror. You can change the file source here.
#wget http://dev.mysql.com/get/Downloads/MySQL-5.7/$file
wget http://mysql.he.net/Downloads/MySQL-5.7/$FILE
#Signature from http://dev.mysql.com/downloads/mysql/
signature='e8c10d4600fc42bf8e111246982a57f4'
match=`md5 -q $FILE`
if [ $signature != $match ]
then
echo "md5 sums mismatch"
return
else
echo "md5 OK"
done
tar xfvz $FILE
echo "stopping mamp"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld nginx
echo "creating backup"
sudo rsync -a /Applications/MAMP ~/Desktop/MAMP-Backup
echo "copy bin"
sudo rsync -av mysql-5.7.*/bin/* /Applications/MAMP/Library/bin/ --exclude=mysqld_multi --exclude=mysqld_safe
echo "copy share"
sudo rsync -av 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/
echo "starting mamp"
ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
sudo /Applications/MAMP/bin/start.sh
echo "migrate to new version"
sudo chmod -R 777 /Applications/MAMP/db/mysql/
/Applications/MAMP/Library/bin/mysql_upgrade --user=root --password=root --host=localhost --port=3306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment