mysql版本升级 5.7.21-8.0.30
当前MySQL版本为:5.7.21
升级前准备,了解5.7和8.0版本有何区别,本文主要为升级操作文档,具体建议参考官方文档,概括性的有以下几点:
》默认字符集由latin1变为utf8mb4
》支持隐藏索引,索引可以被隐藏和显示
》用户创建,修改和授权
》密码认证插件变更,为了避免连接问题,仍可以采用5.7的mysql_native_password认证插件
》支持窗口函数等
》sql_mode参数默认值变化,8.0版本sql_mode不支持NO_AUTO_CREATE_USER
以下为升级8.0需要配置文件中新增的参数配置
#for8.0 sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION character-set-server = utf8mb4 collation_server = utf8mb4_general_ci basedir = /home/mysql8 skip_ssl default_authentication_plugin=mysql_native_password
环境说明:我是本机部署了两个mysql 实例,分别为3306和3307,3306为主节点
首先升级实例3307 (从库)
[root@localhost mysql]# ./bin/mysql -uroot -p -S /home/mysql/3307/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.21-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show variables like 'innodb_fast_shutdown'; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | innodb_fast_shutdown | 1 | +----------------------+-------+ 1 row in set (0.01 sec) mysql> set global innodb_fast_shutdown=0; Query OK, 0 rows affected (0.00 sec)
mysql> shutdown;
mysql> exit Bye
[root@localhost mysql8]# cd /home/mysql8 [root@localhost mysql8]# ./bin/mysqld_safe --defaults-file=/home/mysql/3307/my.cnf &
登录重新查看版本以及主从情况和数据
[root@localhost mysql]# ./bin/mysql -uroot -p -S /home/mysql/3307/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 8.0.30 MySQL Community Server - GPL Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select version(); +-----------+ | version() | +-----------+ | 8.0.30 | +-----------+ 1 row in set (0.01 sec) mysql> start slave; Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for source to send event Master_Host: 192.168.53.123 Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000007 Read_Master_Log_Pos: 154 Relay_Log_File: relay-log.000011 Relay_Log_Pos: 370 Relay_Master_Log_File: mysql-bin.000007 Slave_IO_Running: Yes Slave_SQL_Running: Yes ... ...
升级完成,3306实例主库操作同上
升级过程错误汇总:
1、启动失败,提示信息如下
经对 msyqld_safe 启动文件查看发现变量MY_PWD=`pwd`,执行启动得时候不能使用绝对路径,此变量需要获取当前路径,先进入mysql8 目录下执行./msyqld_safe --defaults-file="配置文件" 及恢复正常
如下信息说明现在启动后得配置文件使用得即为指定得配置文件
2、启动报错,日志如下图,此报错说设置utf8_general_ci设置utf8mb4,修改配置文件
3、启动报错,根据日志错误提示mysql5.7.21不支持innodb_dast_shutdown = 2 得时候升级
标签:
mysql
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)