为什么升级到MySQL 8.0
升级之前需要了解
schema,mysql,information_schema,performance_schema,sys
比如:密码测试 mysql_native_password → caching_sha2_password
2. 关键词是不是兼容
https://dev.mysql.com/doc/refman/8.0/en/keywords.html
关键词 added in查询
3. SQL是不是兼容
Group by处理上的不兼容,触发器,存储过程
5.6 可以跑select id,count(*)from group by name;
5.7,8.0是不是允许的 sql_mode控制
4. 数据文件存储格式是不是可以直接升级
Perconal 和 mysql 存储引擎一直,可以完全兼容
5. 现有应用的兼容性是否满足
自定义函数,一些不规范的SQL语句等等
6. 密码策略
What Is New in MySQL 8.0
作为DBA需要基本了解8.0的一些功能,参考:https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html
升级准备事项
已经了解8.0的特性,应对升级需要事先进行验证和准备工作
升级前检查
Mysql8.0还是提供了很多方便,不像之前一样5.6升级5.7那样。现在可以通过mysql shell进行确认。
https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-utilities-upgrade.html
下面2种方式
- #mysqlsh root:123456@192.168.244.130:3410 -e 'util.checkForServerUpgrade({"targetVersion":"8.0.19","configPath":"/etc/my3410.cnf"})';
- MySQL JS > util.checkForServerUpgrade('root@192.168.244.130:3410', {"password":"123456", "targetVersion":"8.0.11", "configPath":"/etc/my3410.cnf"})
按照提示的要求进行更改
虽然shell做的很好,但还是存在一些缺陷。
比如以下内容都不会存在提示:
1. basedir,
2. sql_mode ,
3. 半同步配置,
4. 密码策略:default_authentication_plugin = mysql_native_password
开始升级
官网下载对应的tar包
https://downloads.mysql.com/archives/community/
下面是单机升级,高可用架构下 需要先升级从库,在逐步升级主库。
执行mysql_upgrade命令,会提示如下:
- #/mysql8.0.19/bin/mysql_upgrade -uroot -p123456
在MySQL 8中mysql_upgrade客户端现已弃用。升级客户端执行的操作现在由服务器完成。
要升级,请使用较旧的数据目录启动新的 MySQL 二进制文件。自动修复用户表。升级后不需要重新启动。
所以必须在测试环境模拟准备对应SQL语句
正确操作如下:
1)登录服务器进行正常关闭:innodb_fast_shutdown是默认是1,常常认为是安全关闭
关闭innodb参数确认
- mysql> show variables like 'innodb_fast_shutdown';+----------------------+-------+| Variable_name | Value |+----------------------+-------+| innodb_fast_shutdown | 1 |+----------------------+-------+1 row in set (0.00 sec)
确保数据都刷到硬盘上,更改成0
- mysql> set global innodb_fast_shutdown=0;Query OK, 0 rows affected (0.01 sec)
- mysql> shutdown;Query OK, 0 rows affected (0.00 sec)
- *进行备份。
2)用mysql8.0.19客户端直接启动
启动mysql服务
- [root@ss30 bin]# /opt/mysql8.0.19/bin/mysqld_safe --defaults-file=/etc/my3400.cnf --user=mysql &
- [1] 15400
- [root@ss30 bin]# 2020-04-25T13:07:16.591560Z mysqld_safe Logging to '/opt/data3400/logs/error.log'.
- 2020-04-25T13:07:16.636879Z mysqld_safe Starting mysqld daemon with databases from /opt/data3400/mysql
- ##打开另一个窗口查看error日志
- [root@ss30 ~]# tail -f /opt/data3400/logs/mysql_error.log
登录服务器确认
- [root@ss30 ~]# mysql -uroot -p -S /opt/data3400/mysql/mysql.sockEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 10Server version: 8.0.19 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> select version();+-----------+| version() |+-----------+| 8.0.19 |+-----------+1 row in set (0.01 sec)
无myisam引擎
- mysql> SELECT table_schema,table_name,engine FROM information_schema.tables where engine!='InnoDB';
剩下的就是验证 和 业务确认否应用正常。
总结
整个从升级准备开始 到结束,中间包含很多细致的工作。比如版本确认,功能确认,测试,准备,备份,验证,高可用切换等等。前期需要投入很多精力进行准备,这样才能做到一步到位。
升级完,下一步踏上8.0的使用旅程。
MFC项目在vs2017编译正常无报错,但是升级vs2019后一打开项目就报如下错误。 项...
本文实例为大家分享了javascript实现倒计时提示框的具体代码,供大家参考,具体...
本文实例为大家分享了vue实现按钮切换图片的具体代码,供大家参考,具体内容如下...
今天看到个不错的网页播放器,感觉不错,大家可以测试 我写的一个播放器网页: ...
首先到这里下载其源码。里面东西挺多的,我们基本上可以把它放到两个文件夹就是...
这5个PHP编程中的不良习惯,一定要改掉 PHP世界上最好的语言! 测试循环前数组是...
目录 1. C语言文件接口(库函数) 1.1 fopen 1.2 fclose 1.3 fread 1.4 fwrite 1.5...
由于固态驱动器(SSD)的速度比传统的硬盘驱动器(HDD)快得多,并且价格越来越便宜...
在大三的时候,一直就想搭建属于自己的一个博客,但由于各种原因,最终都不了了...
目录 读者基础 ?微服务架构梳理 https://www.coder4.com/homs_online/ ? ? 读者...