是否可以将MAMP MySQL库升级到5.7? 我目前正在运行5.6(我升级到使用MAMP的升级脚本 ) 或者我需要在我的系统上本机安装MySQL吗? (macOS 10.11 El Capitan)
如果有人能指出我正确的方向......谢谢!
答案 0 :(得分:11)
将MAMP升级到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
答案 1 :(得分:7)
更新:Version 5.0 of MAMP now includes MySQL 5.7 already in the installer!只需升级您的核心MAMP设置,您就可以使用MySQL,而不必像这样跳过技术箍。
在下面留下答案,作为任何需要它的人的参考。
虽然我已经在这里阅读了这些答案和评论 - 以及GitHub上的一些类似的链接教程等等 - 但在一些教程中有一些让我感到困惑的事情。例如设置chmod -O o+rw
的说明,甚至是关于创建指向/tmp/mysql.sock
的符号链接的评论;当开箱即用的MAMP应该是自包含而不需要这样的改变时,为什么呢?所以这里是根据我在Mac OS 10.3.4(High Sierra)上为MAMP 4.4.1升级MySQL的经验而编写的说明。
首先,获取MySQL 5.7的macOS二进制文件的副本;请注意,在我发布此答案时,MySQL 5.7.22是当前版本,因此请将此URL调整为您可能要使用的任何新版本:
curl -OL https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-macos10.13-x86_64.tar.gz
像这样解压缩:
tar xfvz mysql-5.7*
通过Rsync将bin/
和share/
内容复制到MAMP中,如下所示:
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/
像这样复制现有的MySQL 5.6数据库目录;请注意,在升级过程中暂时需要mysql56
目录,但在完成MySQL 5.7升级的其余部分后可以将其丢弃:
sudo cp -r /Applications/MAMP/db/mysql56 /Applications/MAMP/db/mysql57
完成后,删除像这样的MySQL数据库特定二进制文件进行升级:
sudo rm -rf /Applications/MAMP/db/mysql57/mysql/innodb_*
sudo rm -rf /Applications/MAMP/db/mysql57/mysql/slave_*
而不是将权限更改为o+rw
,只需将DB目录的所有者更改为当前用户;这符合MAMP如何安装这些东西:
sudo chown -R ${USER}:admin /Applications/MAMP/db/mysql57
现在运行此Sed命令来调整mysqld_safe
脚本以指向新的MySQL 5.7路径;您可以在文本编辑器中打开此文件,并将mysql56
的所有实例更改为mysql57
:
sed -i.bak 's/mysql56/mysql57/g' /Applications/MAMP/Library/bin/mysqld_safe
最后,如果您使用MAMP并设置my.cnf
文件,则应在/Applications/MAMP/conf/my.cnf
中设置...但是通过此升级,MAMP中my.cnf
的默认搜索路径将是/usr/local/mysql/etc/
而不是预期的/Applications/MAMP/conf/
,因为这是新二进制文件期望设置的地方。很明显,我们现在不打算重新编译MySQL,所以最简单/最简单的做法是让你的MAMP设置再次真正可移植就是改变startMysql.sh
中的这一行:
/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 &
对此;请注意我们在所有otgers之前添加--defaults-extra-file=
选项:
/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 &
完成所有命令行工作后,通过应用程序启动MAMP,启动MySQL和Apache服务器,然后返回命令,如运行此命令升级数据库:
/Applications/MAMP/Library/bin/mysql_upgrade --user=root --password=root --port=3306 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --force
最后运行此命令以便为MAMP路径而不是mysql.sock
路径正确设置/tmp/mysql.sock
:
/Applications/MAMP/Library/bin/mysql_config_editor --verbose set --socket=/Applications/MAMP/tmp/mysql/mysql.sock
完成所有操作后,您确认MySQL正在按预期运行,只需抛出旧的MySQL 5.6目录:
sudo rm -rf /Applications/MAMP/db/mysql56
完成所有这些工作后,您应该全部设置为在MAMP 4.4.1下干净地使用MySQL 5.7。
答案 2 :(得分:1)
我在JakeGould的出色锻炼中遇到了升级到MySQL 5.7.22的问题。
更新程序在El Capitan和MySQL 5.7.18上运行良好。
我已为此过程编写了更新的bash脚本:
#!/bin/sh
curl -OL https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-macos10.12-x86_64.tar.gz
tar xfvz mysql-5.7*
echo "Stopping MAMP"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld
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 "Building Mysql 5.7 Folder"
sudo cp -r /Applications/MAMP/db/mysql56 /Applications/MAMP/db/mysql57
sudo rm -rf /Applications/MAMP/db/mysql57/mysql/innodb_*
sudo rm -rf /Applications/MAMP/db/mysql57/mysql/slave_*
sudo chown -R ${USER}:admin /Applications/MAMP/db/mysql57
sed -i.bak 's/mysql56/mysql57/g' /Applications/MAMP/Library/bin/mysqld_safe
echo "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 &"
read -p "With all of that command line work done, launch MAMP via the application, start the MySQL and Apache servers."
read -p "Press [Enter] key to start migration..."
echo "Starting MySQL"
/Applications/MAMP/Library/bin/mysql_upgrade --user=root --password=root --port=3306 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --force
echo "Migrate, finaly, to new version"
/Applications/MAMP/Library/bin/mysql_config_editor --verbose set --socket=/Applications/MAMP/tmp/mysql/mysql.sock