MySQL5.5升级至5.7
发表于:2025-11-10 作者:千家信息网编辑
千家信息网最后更新 2025年11月10日,一、准备工作新的服务器(10.12.21.184),作为从库在21.184上下载MySQL5.6、5.7的最新稳定版本的二进制包hostrole10.12.21.120master10.12.21.1
千家信息网最后更新 2025年11月10日MySQL5.5升级至5.7
一、准备工作
- 新的服务器(10.12.21.184),作为从库
- 在21.184上下载MySQL5.6、5.7的最新稳定版本的二进制包
| host | role |
|---|---|
| 10.12.21.120 | master |
| 10.12.21.184 | slave |
二、操作
1. 主从搭建
- xtrbackup全备(20.120)
- 根据全备在20.184上启动新的5.5数据库,作为20.120的从库
- 启动主从,等待从库追上主库
2. 升级从库
1.解压文件包
cd /data0/mysql_updatetar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gzcd /usr/localln -s /data0/mysql_upgrade/mysql-5.6.40-linux-glibc2.12-x86_64 mysql2.添加环境变量
export PATH=/usr/local/mysql/bin:$PATHexport LD_LIBRARY_PATH=/usr/local/mysql/lib:$LD_LIBRARY_PATH3.修改配置5.6文件
cd /data0/mysql/config/cp my.cnf my56.cnf#修改basedir,并注释该参数# innodb_additional_mem_pool_size = 32M 从MySQL 5.6.3开始, #innodb_additional_mem_pool_size已被弃用,并将在未来的MySQL版本中删除。#table_cache=8192#thread_concurrency=48basedir=/usr/local/mysql/plugin_dir=/usr/local/mysql/lib/plugin新增:skip-slave-startsql_mode=''4.关闭快速关机参数
[root@localhost (none)]>set global innodb_fast_shutdown=0;Query OK, 0 rows affected (0.00 sec)[root@localhost (none)]>show variables like 'innodb_fast_shutdown';+----------------------+-------+| Variable_name | Value |+----------------------+-------+| innodb_fast_shutdown | 0 |+----------------------+-------+1 row in set (0.00 sec)5.关闭从库
[root@localhost local]# /data0/mysql/product/bin/mysqladmin --defaults-extra-file=/data0/mysql/config/user.root.cnf shutdown6.启动
[root@localhost local]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/data0/mysql/config/my56.cnf &[1] 9446[root@localhost local]# 180605 15:37:12 mysqld_safe Logging to '/data0/mysql/mysqllog/logfile/mysqld.err'.180605 15:37:12 mysqld_safe Starting mysqld daemon with databases from /data0/mysql/dbdata- 启动的时候会出现大量如下报错日志,不影响启动,属于正常现象
- 是因为MySQL5.5和5.6的表结构不同
2018-06-05 15:37:16 10312 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_digest' has the wrong structure2018-06-05 15:37:16 10312 [ERROR] Native table 'performance_schema'.'users' has the wrong structure2018-06-05 15:37:16 10312 [ERROR] Native table 'performance_schema'.'accounts' has the wrong structure2018-06-05 15:37:16 10312 [ERROR] Native table 'performance_schema'.'hosts' has the wrong structure2018-06-05 15:37:16 10312 [ERROR] Native table 'performance_schema'.'socket_instances' has the wrong structure2018-06-05 15:37:16 10312 [ERROR] Native table 'performance_schema'.'socket_summary_by_instance' has the wrong structure2018-06-05 15:37:16 10312 [ERROR] Native table 'performance_schema'.'socket_summary_by_event_name' has the wrong structure2018-06-05 15:37:16 10312 [ERROR] Native table 'performance_schema'.'session_connect_attrs' has the wrong structure2018-06-05 15:37:16 10312 [ERROR] Native table 'performance_schema'.'session_account_connect_attrs' has the wrong structure7.升级5.6
/usr/local/mysql/bin/mysql_upgrade -S /data0/mysql/dbdata/mysql.sock -uroot -pXXXXX8.关闭5.6的库
[root@localhost local]# /usr/local/mysql/bin/mysqladmin--defaults-extra-file=/data0/mysql/config/user.root.cnf shutdown180605 16:02:30 mysqld_safe mysqld from pid file/data0/mysql/dbdata/mysqld.pid ended[1]+ Done /usr/local/mysql/bin/mysqld_safe --defaults-file=/data0/mysql/config/my56.cnf9.解压MySQL5.7并建立软连接
cd /usr/local/[root@localhost local]# ln -s /data0/mysql_upgrade/mysql-5.7.22-linux-glibc2.12-x86_64 mysql10.修改配置文件,启动MySQL5.7
[root@localhost local]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/data0/mysql/config/my57.cnf &[1] 11262[root@localhost local]# 2018-06-05T08:11:10.690409Z mysqld_safe Logging to '/data0/mysql/mysqllog/logfile/mysqld.err'.2018-06-05T08:11:10.774997Z mysqld_safe Starting mysqld daemon with databases from /data0/mysql/dbdata- 出现如下报错为正常现象
- 原因是5.6与5.7的系统表结构不同
018-06-05T08:11:14.340649Z 0 [ERROR] Native table 'performance_schema'.'events_transactions_current' has the wrong structure2018-06-05T08:11:14.340681Z 0 [ERROR] Native table 'performance_schema'.'events_transactions_history' has the wrong structure2018-06-05T08:11:14.340717Z 0 [ERROR] Native table 'performance_schema'.'events_transactions_history_long' has the wrong structure2018-06-05T08:11:14.340774Z 0 [ERROR] Native table 'performance_schema'.'events_transactions_summary_by_thread_by_event_name' has the wrong structure2018-06-05T08:11:14.340828Z 0 [ERROR] Native table 'performance_schema'.'events_transactions_summary_by_account_by_event_name' has the wrong structure2018-06-05T08:11:14.340869Z 0 [ERROR] Native table 'performance_schema'.'events_transactions_summary_by_user_by_event_name' has the wrong structure2018-06-05T08:11:14.340911Z 0 [ERROR] Native table 'performance_schema'.'events_transactions_summary_by_host_by_event_name' has the wrong structure2018-06-05T08:11:14.340948Z 0 [ERROR] Native table 'performance_schema'.'events_transactions_summary_global_by_event_name' has the wrong structure2018-06-05T08:11:14.345136Z 0 [ERROR] Incorrect definition of table performance_schema.users: expected column 'USER' at position 0 to have type char(32), found type char(16).11.升级5.7(时间较长,放在后台)
nohup /usr/local/mysql/bin/mysql_upgrade -S /data0/mysql/dbdata/mysql.sock -uroot -proot 2>&1 >/data0/mysql_upgrade/56to57.log &www_fangdd_site.fdd_patsNote : TIME/TIMESTAMP/DATETIME columns of old format have been upgraded to the new format.status : OK`cat`.`alteration`Running : ALTER TABLE `cat`.`alteration` FORCEstatus : OK`cat`.`app_data_command_1`Running : ALTER TABLE `cat`.`app_data_command_1` FORCEstatus : OK12.重启MySQL5.7数据库
[root@localhost mysql_upgrade]# /usr/local/mysql/bin/mysqladmin--defaults-extra-file=/data0/mysql/config/user.root.cnf shutdown[root@localhost mysql_upgrade]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/data0/mysql/config/my57.cnf &三、升级后需要注意的问题
1.sql_mode
MySQL5.7默认为下列sql_mode,为避免以前语句不规范带来的隐患,将sql_mode设置为''
sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
升级
文件
不同
主从
参数
数据
数据库
版本
现象
结构
全备
配置
上下
二进制
原因
变量
后台
日志
时候
时间
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
将exe文件存放到数据库中
应用软件开发工程师FA
越秀区软件开发工程师
智能化软件开发报价收费套餐
中国移动游戏服务器
若依数据库在哪实现的
接听电话数据库
web数据库技术网页设计
中国交通银行的网络安全措施
新世界狂欢服务器
屏幕共享软件开发厂家现货
现代网络技术机械工业出版社
手机卡欠费一直显示服务器异常
关于网络安全的漫画简笔画
关于asc数据库正确的说法是
网络技术未来教育pdf
福建网络安全审计系统咨询贵不贵
网络安全现状概述
网络安全是研究生哪个方向
保定市维云网络技术
网络安全与管理专业毕业论文
宁波软件开发系统
qt工控软件开发
易语言修改acc数据库
网络安全个人资料保护案例
智能化软件开发报价收费套餐
浙大墓志数据库如何查询
软件开发计算过程
宝马汽车如何调用油箱数据库
网络安全与游戏