MySQL8.0 升级

news2024/11/20 3:18:08

MySQL8.0.30 升级到 MySQL8.0.32

备份旧数据

root@LAPTOP-FPIQJ438:/data/backup# xtrabackup --backup --user=root --password=123456 --socket=/tmp/mysql.sock --target-dir=/data/backup/
2024-01-08T16:46:38.987687+08:00 0 [Note] [MY-011825] [Xtrabackup] recognized server arguments: --datadir=/usr/local/mysql-8.0/data/
2024-01-08T16:46:38.988068+08:00 0 [Note] [MY-011825] [Xtrabackup] recognized client arguments: --backup=1 --user=root --password=* --socket=/tmp/mysql.sock --target-dir=/data/backup/
xtrabackup version 8.0.35-30 based on MySQL server 8.0.35 Linux (x86_64) (revision id: 6beb4b49)
240108 16:46:39  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/tmp/mysql.sock' as 'root'  (using password: YES).
Failed to connect to MySQL server as DBD::mysql module is not installed at - line 1548.
2024-01-08T16:46:39.050470+08:00 0 [Note] [MY-011825] [Xtrabackup] Connecting to MySQL server host: localhost, user: root, password: set, port: not set, socket: /tmp/mysql.sock
2024-01-08T16:46:39.058512+08:00 0 [Note] [MY-011825] [Xtrabackup] Using server version 8.0.30
2024-01-08T16:46:39.060647+08:00 0 [Note] [MY-011825] [Xtrabackup] Executing LOCK INSTANCE FOR BACKUP ...
2024-01-08T16:46:39.064725+08:00 0 [ERROR] [MY-011825] [Xtrabackup] Found tables with row versions due to INSTANT ADD/DROP columns
2024-01-08T16:46:39.064838+08:00 0 [ERROR] [MY-011825] [Xtrabackup] This feature is not stable and will cause backup corruption.
2024-01-08T16:46:39.064843+08:00 0 [ERROR] [MY-011825] [Xtrabackup] Please check https://docs.percona.com/percona-xtrabackup/8.0/em/instant.html for more details.
2024-01-08T16:46:39.064846+08:00 0 [ERROR] [MY-011825] [Xtrabackup] Tables found:
2024-01-08T16:46:39.064849+08:00 0 [ERROR] [MY-011825] [Xtrabackup] test/test
2024-01-08T16:46:39.064851+08:00 0 [ERROR] [MY-011825] [Xtrabackup] Please run OPTIMIZE TABLE or ALTER TABLE ALGORITHM=COPY on all listed tables to fix this issue.

可以发现出现 Found tables with row versions due to INSTANT ADD/DROP columns

错误,优化错误提示中 提到的表

优化表

mysql> OPTIMIZE table test;
+-----------+----------+----------+-------------------------------------------------------------------+
| Table     | Op       | Msg_type | Msg_text                                                          |
+-----------+----------+----------+-------------------------------------------------------------------+
| test.test | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| test.test | optimize | status   | OK                                                                |
+-----------+----------+----------+-------------------------------------------------------------------+
2 rows in set (0.06 sec)

继续备份

root@LAPTOP-FPIQJ438:/data/backup# xtrabackup --backup --user=root --password=123456 --socket=/tmp/mysql.sock --target-dir=/data/backup/

MySQL8.0.30配置文件

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html


[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password


# datadir=/var/lib/mysql
# socket=/var/lib/mysql/mysql.sock


log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid


basedir=/usr/local/mysql-8.0/
datadir=/usr/local/mysql-8.0/data/
socket=/tmp/mysql.sock
character-set-server=UTF8MB4

记住 数据目录datadir ,数据库端口为 默认端口为 3306

获取新版安装包

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz

删除 旧版本的 安装目录文件

root@LAPTOP-FPIQJ438:/usr/local# rm -rf mysql-8.0
root@LAPTOP-FPIQJ438:/etc/init.d# cd /etc/init.d/
root@LAPTOP-FPIQJ438:/etc/init.d# rm -rf mysql

旧版本的配置文件可以不删除,新版本的可以直接使用旧版的配置文件

解压新版本安装包

root@LAPTOP-FPIQJ438:/usr/local# tar xvJf mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz
root@LAPTOP-FPIQJ438:/usr/local# mv mysql-8.0.32-linux-glibc2.12-x86_64 mysql-8.0

新版本初始化

初始化之前要将旧版本的数据目录下的数据文件全部删除,否则初始化失败

进入到新版本bin目录

root@LAPTOP-FPIQJ438:/usr/local# mkdri data
root@LAPTOP-FPIQJ438:chown -R mysql.mysql /usr/local/mysql-8.0
root@LAPTOP-FPIQJ438:/usr/local# cd mysql-8.0/bin/
root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin#
root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin#
root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin#
root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin# pwd
/usr/local/mysql-8.0/bin

按照旧版本的配置文件初始化

./mysqld --user=mysql --basedir=/usr/local/mysql-8.0 --datadir=/usr/local/mysql-8.0/data/ --initialize

查看临时密码,通过配置文件中的 mysqld 进程日志 log-error=/var/log/mysqld.log

root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin# vim /var/log/mysqld.log

临时密码为 rFf#SqPTw2q/

关闭旧版本数据库

root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp6       0      0 :::33060                :::*                    LISTEN      1402/mysqld
tcp6       0      0 :::3306                 :::*                    LISTEN      1402/mysqld
root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin#
root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin#
root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin#
root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin# kill 1402

启动新版本数据库

进入到/usr/local/mysql-8.0

cp -a /usr/local/mysql-8.0/support-files/mysql.server /etc/init.d/mysql

该命令也会自动在/etc/init.d下创建mysql

授权启动

chmod +x /etc/init.d/mysql
service mysql start

登录修改密码

root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32


Copyright (c) 2000, 2023, Oracle and/or its affiliates.


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>
mysql>
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.00 sec)


mysql> update user set host='%' where user='root';
ERROR 1046 (3D000): No database selected
mysql>
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Database changed
mysql>
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0


mysql>
mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)


mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.01 sec)


mysql>

还原旧版本的数据

service mysql stop                  --关闭新版数据库
rm -rf /usr/local/mysql-8.0/data/*  --删除新版数据库数据


xtrabackup --prepare -uroot -p --target-dir=/data/backup/
xtrabackup --copy-back --target-dir=/data/backup/  --旧版数据库还原到新版数据库
chown -R mysql.mysql /usr/local/mysql-8.0

升级数据库验证

升级命令,目标版本大于8.0.16时,启动使用–upgrade=FORCE参数

root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin# ./mysqld_safe --datadir=/usr/local/mysql-8.0/data/ --upgrade=FORCE &
[1] 1684
root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin# 2024-01-09T06:03:41.032750Z mysqld_safe Logging to '/var/log/mysqld.log'.
2024-01-09T06:03:41.049302Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-8.0/data

查看

root@LAPTOP-FPIQJ438:/usr/local/mysql-8.0/bin# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.32 MySQL Community Server - GPL


Copyright (c) 2000, 2023, Oracle and/or its affiliates.


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>
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+
5 rows in set (0.00 sec)


mysql>
mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Database changed
mysql>
mysql>
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| test           |
+----------------+
1 row in set (0.00 sec)


mysql>
mysql>
mysql> select * from test;
+------+
| id   |
+------+
|    1 |
|    1 |
+------+
2 rows in set (0.00 sec)

可以查到 旧版 test 数据

注意

升级过程前,一定要备份数据,版本的升级方式有所差异

#8.0.16以后的版本
mysqladmin -u root -p shutdown
mysqld_safe --user=mysql --datadir=/path/to/8.0-datadir --upgrade=FORCE &
 
#8.0.16之前的版本
mysql_upgrade -u root -p
mysqladmin -u root -p shutdown
mysqld_safe --user=mysql --datadir=/path/to/8.0-datadir &

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1371091.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

江山易改本性难移之ZYNQ SDK QSPI固化bug及其解决方法

之前在Vivado2018.3通过QSPI方式固化程序时出现问题,显示flash擦除成功,但最后总是不能写入到flash中。 查资料发现从VIVADO 2017.3版本开始,Xilinx官方为了使Zynq-7000和Zynq UltraScale 实现流程相同,在QSPI FLASH使用上做了变化…

VSCode C/C++(gdb)调试指南

1、安装插件 2、F5开启调试 左侧侧边栏->确保打开回调栈 右键函数栈->查看反汇编 3、打印寄存器、函数反汇编等 命令: 查看main反汇编 -exec disassemble /m main 查看寄存器 -exec info r 打印某个变量 -exec print s 或者 --s 打印寄存器,如p…

Git删除远程仓库某次提交记录后的所有提交

1、鼠标右键->git bash here,然后cd切换到代码目录; 2、git log查看提交记录,获取commit id 3、git reset commit id(commit id指要保留的最新的提交记录id) 4、git push --force,强制push 如果出现…

来自一个系统的自白

天空一声巨响,小炫我闪亮登场!初次见面,给大家简单介绍下自己:我是炫我渲染私有云系统,是最新一代的智能渲染集群系统。可以进行私有化部署,在3dsmax、maya等软件中一键完成提交、上传、渲染、下载的任务&a…

强化学习第1天:马尔可夫过程

☁️主页 Nowl 🔥专栏 《强化学习》 📑君子坐而论道,少年起而行之 ​​ 一、介绍 什么是马尔可夫过程?马尔可夫过程是马尔可夫决策过程的基础,而马尔可夫决策过程便是大部分强化学习任务的抽象过程,本文…

人机交互不是人机融合智能

一、人机交互和人机融合智能是两个不同的概念 人机交互是指人类与计算机之间的信息交流和操作方式,包括输入和输出界面、交互技术、用户体验等方面。人机交互的目标是提供用户友好的界面和自然的交互方式,使人类能够与计算机更加高效地进行沟通和协作。 …

BOM简介

1.1 常用的键盘事件 1.1.1 键盘事件 键盘事件触发条件onkeydown按键被按下时触发onkeypress按键被按下时触发onkeyup按键被松开时触发 注意&#xff1a;addEventListener事件不需要加on <script>//1. keydown 按键按下的时候触发,按任意键都触发&#xff0c;也可以识…

PhpPythonC++圆类的实现(OOP)

哎......被投诉了 &#x1f62d;&#x1f62d;&#x1f62d;&#x1f62d;&#x1f62d; 其实也不是小编不更&#xff0c;这不是期末了吗&#xff08;zhaojiekou~~&#xff09;&#xff0c;而且最近学的信息收集和ctf感觉好像没找到啥能更的&#xff08;不过最经还是在考虑更一…

Java中并发下的ThreadlocalRandom

1. 背景 在看同事写的代码的时候发现代码里有很多像&#xff1a; 如果我们想要生成一个随机数&#xff0c;通常会使用Random类。但是在并发情况下Random生成随机数的性能并不是很理想&#xff0c;今天给大家介绍一下JUC包中的用于生成随机数的类–ThreadLocalRandom.&#x…

领英Linkedin自动跳转中国站点的解决方案

linkedin放弃中国市场后&#xff0c;在国内打开linkedin.com&#xff0c;会自动跳转到 linkedin.cn&#xff0c;无法与国际友人在同一个平台上联系。 按照搜到的方法尝试解决&#xff0c;包括修改浏览器默认语言、清除浏览数据、使用软路由上的插件给 linkedin.com设置从国外线…

华为 1+X《网络系统建设与运维(高级)》认证模拟实验上机试题

华为 1X《网络系统建设与运维&#xff08;高级&#xff09;》认证模拟实验上机试题 一、考试背景二、考试说明2.1考试分数说明2.2考试要求2.3考试环境介绍2.4启动考试环境2.5保存答案(非常重要) 三、考试正文3.1注意事项3.2校区内&#xff08;LAN&#xff09;3.2.1任务 1&#…

深入浅出Go语言:匿名函数的原理和实践案例

深入浅出Go语言&#xff1a;匿名函数的原理和实践案例 引言匿名函数的基础实际应用案例一实际应用案例二性能考虑最佳实践与常见错误结语 引言 在Go语言的世界里&#xff0c;有一个功能强大且灵活的编程元素值得每位开发者深入了解——匿名函数。作为Go语言核心特性之一&#…

前端-基础 表格标签 - 基本使用及表头单元格 详解

基本使用 &#xff1a; 主要作用 &#xff1a; 即 主要 用于显示&#xff0c;展示数据&#xff0c;因为它可以让数据显示的非常的规整&#xff0c;可读性非常好。 特别是后台展示数据的时候&#xff0c;能够熟练运用表格就显得很重要。 一个清爽简约的表格能够把繁杂 的…

C2-4.3.1 多个决策树——随机森林

C2-4.3.1 多个决策树——随机森林 参考链接 1、为什么要使用多个决策树——随机森林&#xff1f; 决策树的缺点&#xff1a; A small change in the data can cause a large change in the structure of the decision tree causing instability 即&#xff1a;对数据集 中…

数据库:如何取消mysql的密码

因为调试MySQL数据接口&#xff0c;总是需要输入密码很烦&#xff0c;所以决定取消mysql的root密码&#xff0c; 网上推荐的有两种方法&#xff1a; 1、mysql命令 SET PASSWORD FOR rootlocalhostPASSWORD(); 2、运行 mysqladmin 命令 mysqladmin -u root -p password …

【源码阅读】交易池txs_pool

重要接口&#xff1a; ITxsPool的实现&#xff1a; type TxsPool struct {config TxsPoolConfigchainconfig *params.ChainConfigbc common.IBlockChaincurrentState *state.IntraBlockStatependingNonces *txNoncercurrentMaxGas uint64ctx context.Context //cance…

密码学(一)

文章目录 前言一、Cryptographic Primitives二、Cryptographic Keys2.1 Symmetric key cryptography2.2 asymmetric key cryptography 三、Confidentiality3.1 Symmetric key encryption algorithms3.2 asymmetric key block ciphers3.3 其他 四、Integrity4.1 secure hashing …

【语义解析:连接自然语言与机器智能的桥梁】

语义解析&#xff1a;连接自然语言与机器智能的桥梁 语义解析技术可以提高人机交互的效率和准确性&#xff0c;在自然语言处理、数据分析、智能客服、智能家居等领域都有广泛的应用前景。特别是在大数据时代&#xff0c;语义解析能够帮助企业更快速地从大量的数据中获取有用的…

Helix QAC 2023.4 新版支持C++20语言,带来更多性能提升!

Helix QAC 2023.4 新增功能 Helix QAC 2023.4全面支持MISRA C:2023规则&#xff0c;涵盖100%的指南。此版本还加强了对C20语言的支持&#xff0c;改进了数据流分析性能&#xff0c;并在整个产品中增加了多项用户体验改进。 增强的C20支持 此版本新增了对以下语言特性的支持&a…

永久关闭Windows更新的5种方法

很多家用电脑&#xff0c;如果系统自动更新的话&#xff0c;会变得越来越卡顿&#xff0c;且硬件型号兼容也并不完美。那么我们该如何彻底关闭Win11的自动更新呢&#xff1f;以下准备了5种方法&#xff0c;您可以根据自身实际情况选择合适的方法&#xff01; 一&#xff1a;使…