当前位置:网站首页>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开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担.添加下方名片,即可获取全套学习资料哦
边栏推荐
猜你喜欢
MySQL如何创建用户
Towhee 每周模型
Digicert EV证书签名后出现“证书对于请求用法无效”的解决方案
UE4 蓝图实现AI随机移动
Minecraft 1.18.1, 1.18.2 module development 23.3D animation armor production
What if some fields don't want to be serialized?
UE4 AI行为树实现随机和跟随移动
Does Conway's Law Matter for System Architecture?
A practice arrangement about map GIS (below) GIS practice of Redis
直播 | 7.30 ApacheCon Asia 2022 IOT/IIOT专题,IoTDB PMC 乔嘉林担任出品人
随机推荐
MobaXsterm如何使用
【云原生】DevOps 新纪元 | 史前的惨淡现实
MySQL安装教程
Android Studio 实现登录注册-源代码 (连接MySql数据库)
WiFi、蓝牙、zigbee锁与NB、Cat.1锁的区别
Anatomy of Unreal Playback System (Part 1)
UE4 利用Mixamo自动绑骨并导入虚幻4
MES系统物料管理的五大功能,建议收藏
MySQL 灵魂 16 问,你能撑到第几问?
Js数据类型转化之数组的join方法
Learn about the sequential storage structure of binary tree - heap
递归实现组合型枚举(DAY 92)
Android studio连接MySQL并完成简单的登录注册功能
已更新 联通 电信 tiny模式
MES如何做好生产过程监控,本文给出了详细解答
mysql 查询表 所有字段
vs2022 编译libmodbus源码
MySQL大批量造数据
地牢大师(DAY 95)
迅为RK3568开发板编译Buildroot-全自动编译