如何将 MySQL 5.5.40 升级到 MySQL 5.7
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26480596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can Upgrade MySQL 5.5.40 to MySQL 5.7
提问by matinict
How can I Upgrade MySQL version
如何升级 MySQL 版本
Current MySQL Version: 5.5.40
当前 MySQL 版本:5.5.40
Target MySQL Version: MySQL 5.7
目标 MySQL 版本:MySQL 5.7
OS: CentOS release 6.5 (Final)
操作系统:CentOS 6.5 版(最终版)
采纳答案by Marc Alff
The upgrade path is MySQL 5.5 -> MySQL 5.6 -> MySQL 5.7
升级路径为 MySQL 5.5 -> MySQL 5.6 -> MySQL 5.7
回答by Alex
Probably the quickest way is to dump your older DB version with mysqldumpand restore it into 5.7 fresh DB.
可能最快的方法是使用mysqldump转储旧数据库版本并将其恢复到 5.7 新数据库。
How smooth the process goes, depends on how many dropped features in 5.7 you're using in 5.5.
过程的顺利程度取决于您在 5.5 中使用的 5.7 中删除的功能数量。
In my case, the only feature, that was dropped in 5.7 was timestamp default'0000-00-00 00:00:00' The fix for that was to run sedon dump file and replace ''0000-00-00 00:00:00' with CURRENT_TIMESTAMP
就我而言,在 5.7 中删除的唯一功能是时间戳默认值'0000-00-00 00:00:00' 解决方法是在转储文件上运行sed并替换 ''0000-00-00 00: 00:00' 带有 CURRENT_TIMESTAMP
sed -i.bu 's/'\''0000-00-00 00:00:00'\''/CURRENT_TIMESTAMP/g' fixed_dumo.sql
sed -i.bu 's/'\''0000-00-00 00:00:00'\''/CURRENT_TIMESTAMP/g' fixed_dumo.sql
Afterthat, the fixed_dump.sqlwas imported into fresh 5.7 DB and it worked smoothly. I hope this helps.
之后,fixed_dump.sql被导入到新的 5.7 DB 中,运行顺利。我希望这有帮助。
回答by tanveer ahmad dar
step 1 : take a backup
第 1 步:进行备份
mysqldump --lock-all-tables -u root -p --all-databases > dump.sql
step 2 : remove old mysql
第 2 步:删除旧的 mysql
sudo apt-get remove mysql-server
sudo apt-get autoremove
step 3 : install new version of mysql 5.6
第 3 步:安装新版本的 mysql 5.6
sudo apt-get install mysql-client-5.6 mysql-client-core-5.6
sudo apt-get install mysql-server-5.6
for 5.7
5.7
wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb
sudo dpkg -i mysql-apt-config_0.6.0-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server
step 4 : restore your data
第 4 步:恢复您的数据
mysql -u root -p < dump.sql
mysql -u root -p < dump.sql
回答by Ajeet Khan
I might be late to the party, but easy and fast solution without or minimal downtime could be AWS Database-Migration-Service, which can be used to upgrade your database to a different version as well as to some other server or RDS.
我可能会迟到,但无需停机或停机时间最短的简单快速解决方案可能是 AWS Database-Migration-Service,它可用于将您的数据库升级到其他版本以及其他服务器或 RDS。
I have tried this and converted MySQL5.5 to MySQL5.7 on production without any downtime. Here is a demo for the same - How To Migrate MySQL5.5 to MySQL5.7
我已经尝试过这个,并且在没有任何停机的情况下在生产中将 MySQL5.5 转换为 MySQL5.7。这是相同的演示 -如何将 MySQL5.5 迁移到 MySQL5.7
Steps:
脚步:
Set your current MySQL as master
Create a new instance/server with MySQL5.7 on it with required users
Got to AWS DatabaseMigrationService (DMS) and create a Replication instance
After creating replication instance it will ask to fill up connection detail to source(MySQL5.5) and target(MySQL5.7) databases.
Create task in DMS, which will be the logic on what basis you want to migrate the data (particular database or particular table)
Start the task
When task is completed and data is in sync, just switch the DNS entry pointing to MySQL5.5 to MySQL5.7
将您当前的 MySQL 设置为 master
使用所需的用户创建一个带有 MySQL5.7 的新实例/服务器
到 AWS DatabaseMigrationService (DMS) 并创建复制实例
创建复制实例后,它会要求填写源(MySQL5.5)和目标(MySQL5.7)数据库的连接详细信息。
在 DMS 中创建任务,这将是您要迁移数据(特定数据库或特定表)的依据的逻辑
开始任务
当任务完成并且数据同步时,只需将指向MySQL5.5的DNS条目切换到MySQL5.7
回答by Carlos
Yes. From a "logical upgrade" you can migrate from 5.5 for 5.7. This way: 5.5 -> 5.6 -> 5.7, is necessary only for "in place" upgrade, with data folder.
是的。通过“逻辑升级”,您可以从 5.5 迁移到 5.7。这样:5.5 -> 5.6 -> 5.7,仅用于“就地”升级,带有数据文件夹。
请参阅:https: //www.percona.com/forums/questions-discussions/mysql-and-percona-server/43956-what-is-the-preferred-mysql-upgrade-path-5-5-to-5- 7
回答by Sonpal singh Sengar
Fallow Simple Steps for Upgrade Mysql Version 5.5 to 5.7 .
将 Mysql 版本 5.5 升级到 5.7 的 Fallow 简单步骤。
- wget http://dev.mysql.com/get/mysql-apt-config_0.8.0-1_all.deb
- sudo dpkg -i mysql-apt-config_0.8.0-1_all.deb
- sudo apt-get update
- sudo apt-get install mysql-server
- wget http://dev.mysql.com/get/mysql-apt-config_0.8.0-1_all.deb
- 须藤 dpkg -i mysql-apt-config_0.8.0-1_all.deb
- sudo apt-get 更新
- 须藤 apt-get 安装 mysql-server
回答by Mohideen bin Mohammed
in Mysql,
在 MySQL 中,
step 1:fetch version,
第 1 步:获取版本,
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
step 2:
第2步:
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
step 3:check available mysql repo, yum repolist all | grep mysql
第 3 步:检查可用的 mysql repo,yum repolist all | mysql
will get something like below,
会得到类似下面的东西,
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - S disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - S disabled
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 384
mysql57-community-source MySQL 5.7 Community Server - S disabled
Its preferred to upgrade one by one,
so first upgrade into mysql 5.5 into mysql5.6
最好是一个一个升级,所以先升级成 mysql 5.5 into mysql5.6
step 4:first enable to mysql 5.6 and disable mysql 5.5 and 5.7
第4步:首先启用mysql 5.6并禁用mysql 5.5和5.7
sudo yum-config-manager --enable mysql56-community
sudo yum-config-manager --disable mysql55-community
sudo yum-config-manager --disable mysql57-community
step 5:before upgrade stop service,
第五步:升级前停止服务,
sudo systemctl stop mysql
step 6:Lets ready to upgrade,
第 6 步:让我们准备升级,
yum update
you are successfully upgrade into mysql5.6
您已成功升级到mysql5.6
now repeat step 4 to 6to upgrade into 5.7
现在重复步骤 4 到 6升级到 5.7
sudo yum-config-manager --disable mysql56-community
sudo yum-config-manager --enable mysql57-community
and then
进而
yum update
mysql --version
successfully upgraded into mysql 5.7 dont forgot restart service,
成功升级到mysql 5.7别忘了重启服务,
systemctl start mysql
回答by mrbaron666
After a bunch of failed attempts I have concluded it down to:
经过一系列失败的尝试后,我将其总结为:
- To upgrade from 5.5, go to 5.6 first and then to 5.7
- Save the datafolders and install a fresh installation of 5.7
- 要从 5.5 升级,请先转到 5.6,然后再转到 5.7
- 保存数据文件夹并安装 5.7 的全新安装
Both need the apt-config mentioned in all above comments.
两者都需要上述所有评论中提到的 apt-config 。
The kicker is to run sudo apt install mysql-**community**-server
踢球者是跑 sudo apt install mysql-**community**-server
回答by rakesh
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server-5.6