当前位置:网站首页>MySQL 5.7 upgrade to 8.0 detailed process
MySQL 5.7 upgrade to 8.0 detailed process
2022-08-02 06:05:00 【m0_66557301】
一、升级前准备
1.1.MySQL提供mysql-shell验证方式,It can be downloaded and verified:
下载shell验证文件:
https://cdn.mysql.com/archives/mysql-shell/mysql-shell-8.0.27-linux-glibc2.12-x86-64bit.tar.gz
Verify that the upgrade can be successful(Several errors occurred during verification and were not handled,No issues were found after the upgrade,If it is a production environment, be careful)
# 验证mysql升级
[[email protected]] tar -xf mysql-shell-8.0.27-linux-glibc2.12-x86-64bit.tar.gz
[[email protected]] cd mysql-shell-8.0.27-linux-glibc2.12-x86-64bit/bin
[[email protected]] ./mysqlsh -uroot -p'123456' -S /tmp/mysql.sock -e "util.checkForServerUpgrade()"
1.2. 备份原数据库(Prevent problems during the upgrade process,导致数据丢失,Off-site backup is recommended under certain conditions)
[[email protected]] mysqldump -uroot -p'123456' --all-databases --lock-tables=0 > all.sql.bak.20220412
[[email protected]] mv all.sql.bak.20220412 /data/backup/mysql/
1.3.下载MySQL8.0
下载地址:mysql:https://downloads.mysql.com/archives/community/
选择文件:mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz
# 解压mysql8.0:
[[email protected]] tar -xf mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz
# 移动到指定目录
[[email protected]] mv mysql-8.0.27-linux-glibc2.12-x86_64 /usr/local/mysql8
# 更改文件夹所属
[roo[email protected]] chown -R mysql.mysql /usr/local/mysql8/
二、Upgrade process configuration
2.1. 修改mysql配置文件,主要是mysql8.0
部分,及sql_mode中的NO_ENGINE_SUBSTITUTION
# 编辑配置文件
[[email protected]] vim /etc/my.cnf
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld]
log-bin=mysql-bin
server-id=170
character_set_server=utf8
init_connect='SET NAMES utf8'
#basedir=/usr/local/mysql
#datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/run/mysqld/mysqld.pid
#不区分大小写
lower_case_table_names =1
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
max_connections=5000
default-time_zone = '+8:00'
max_allowed_packet = 32M
#default_password_lifetime=90
#wait_timeout=600
# mysql8.0 add
collation-server=utf8_general_ci
basedir=/usr/local/mysql8
datadir=/usr/local/mysql/data
skip_ssl
default_authentication_plugin=mysql_native_password
2.2 开始升级
# 进入原mysql命令行
[[email protected]] mysql -uroot -p'123456'
# 查看mysql版本
mysql> select version();
+------------+
| version() |
+------------+
| 5.7.26-log |
+------------+
1 row in set (0.00 sec)
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.00 sec)
mysql> shutdown;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
使用安全模式启动mysql8.0,正常启动后可以进入到mysql命令行,如果没启动成功,需要查看日志cat /var/log/mysqld.log
解决后,再进入命令行
# 使用mysql8.0启动
[[email protected]] /usr/local/mysql8/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
# 进入mysql命令行
[[email protected]] mysql -uroot -p'123456'
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.27 |
+-----------+
1 row in set (0.00 sec)
mysql> exit;
Bye
2.2 配置环境变量
[[email protected]] vim /etc/profile
# add mysql
export PATH=$PATH:/usr/local/mysql8/bin
# 使环境变量生效
[[email protected]] source /etc/profile
View the client version configuration
# 验证版本
[[email protected]] which mysql
/usr/local/mysql8/bin/mysql
# 查看版本
[[email protected]] mysql -V
mysql Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL)
If the client version is incorrect,可以修改软链接,再重新查看
# 修改软链接
[[email protected]] ln -snf /usr/local/mysql8/bin/mysql /usr/bin/mysql
三、配置启动项
[[email protected]] cp /usr/local/mysql8/support-files/mysql.server /etc/init.d/mysqld
# 修改启动项目
[[email protected]] vim /etc/init.d/mysqld
# 修改目录位置
basedir=/usr/local/mysql8
datadir=/usr/local/mysql/data
# Add to startup list
[[email protected]] chkconfig --add mysqld
# Refresh startup information
[[email protected]] systemctl daemon-reload
# 查看启动项列表
[[email protected]] chkconfig --list
Restarting the server was unsuccessful,There is no error when starting upmysqld.pid文件,Started successfully after creation
# Restart failed to createmysqld.pid文件处理方法
[[email protected]] cat /var/log/mysqld.log
[[email protected]] cd /run
[[email protected]] mkdir mysqld
[[email protected]] chown -R mysql.mysql ./mysqld
[[email protected]] cd mysqld
[[email protected]] touch mysqld.pid
[[email protected]] chown -R mysql.mysql ./mysqld.pid
[[email protected]] service mysqld start
Starting MySQL.. SUCCESS!
先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在.深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小.自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前.因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担.添加下方名片,即可获取全套学习资料哦
边栏推荐
- 分享|5G+智慧工业园区解决方案(附PDF)
- 讯飞AIUI智能机器人5-----让器理解你(语音技术综合应用)
- Mysql 回表
- [Errno 13] Permission denied:’/usr/local/share/jupyter’
- The practice of alibaba, data synchronization component canal
- 认识消防报警联网中CAN光纤转换器的光纤接口和配套光纤线缆
- 选择黑盒测试用例设计方法的综合策略方案总结
- 【云原生】DevOps 新纪元 | 史前的惨淡现实
- 2022 Huawei Software Elite Challenge (Preliminary) - Summary
- UE4 利用Mixamo自动绑骨并导入虚幻4
猜你喜欢
随机推荐
acwing 最大数
UE4 利用Mixamo自动绑骨并导入虚幻4
Centos7.9+mysql8.0开启指定IP远程连接数据库
MySQL如何创建用户
A practice arrangement about map GIS (below) GIS practice of Redis
2022河南萌新联赛第(四)场:郑州轻工业大学 A - ZZULI
ffmpeg基本命令
元空间内存溢出
WiFi、蓝牙、zigbee锁与NB、Cat.1锁的区别
Redis常见题型
行测不会概念
Towhee 每周模型
Deep Blue Academy - Handwritten VIO Homework - Chapter 2
matlab simulink 飞机飞行状态控制
【无标题】
mysql练习题
使用pycharm debug 深度学习代码
MySQL如何对SQL做prepare预处理(解决IN查询SQL预处理仅能查询出一条记录的问题)
“数字化重构系统,搞定 CEO 是第一步”
gergovia's deal tijie