MySQL8.0 升级

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.socklog-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pidbasedir=/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.32Copyright (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 -ADatabase changed
mysql>
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql>
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 - GPLCopyright (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 -ADatabase 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.mzph.cn/news/609539.shtml

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

相关文章

CPU控制的独立式键盘扫描实验

#include<reg51.h> //包含51单片机寄存器定义的头文件 sbit S1P1^4; //将S1位定义为P1.4引脚 sbit S2P1^5; //将S2位定义为P1.5引脚 sbit S3P1^6; //将S3位定义为P1.6引脚 sbit S4P1^7; //将S4位定义为P1.7引脚 unsigned char keyval; /…

连接服务器Mysql出现“Host ‘xxx‘ is not allowed to connect to this MySQL server“解决方法

远程连接提示&#xff1a;Host xxx is not allowed to connect to this MySQL server。是mysql未开启mysql远程访问权限导致。 登录mysql&#xff0c;发现出现了 Access denied for user ‘root’ T’localhost (using password: YES) 此时先找到my.cnf文件,使用命令mysql --…

http跟https有什么区别?

HTTPS和HTTP的概念&#xff1a; HTTP&#xff1a;是互联网上应用最为广泛的一种网络协议&#xff0c;是一个客户端和服务器端请求和应答的标准&#xff08;TCP&#xff09;&#xff0c;用于从WWW服务器传输超文本到本地浏览器的传输协议&#xff0c;它可以使浏览器更加高效&am…

智慧灌溉解决方案(基于物联网的智能灌溉系统)

​ 详情&#xff1a;智慧水务数字孪生安全监测解决方案提供商-星创 (key-iot.com.cn) 随着农业IOT的快速发展,智慧灌溉正成为提高农业水资源利用效率,实现精准灌溉的重要技术手段。完整的智慧灌溉系统由实地各类传感设备以及后台管理软件平台组成,可以实现对整个灌区的监测和精…

python(17)--文件的输入/输出

前言 在Python中&#xff0c;文件文本操作是非常重要的&#xff0c;主要有以下几个原因&#xff1a; 数据持久性&#xff1a;当你需要长期存储数据&#xff0c;如用户的个人信息、交易记录或数据库元数据等&#xff0c;将数据保存在文件中是一种常见的方法。文件系统提供了持…

非线性最小二乘问题的数值方法 —— 从高斯-牛顿法到列文伯格-马夸尔特法 (I)

Title: 非线性最小二乘问题的数值方法 —— 从高斯-牛顿法到列文伯格-马夸尔特法 (I) 文章目录 前言I. 从高斯-牛顿法II. 到阻尼高斯-牛顿法III. 再到列文伯格-马夸尔特法1. 列文伯格-马夸尔特法的由来2. 列文伯格-马夸尔特法的说明说明一. 迭代方向说明二. 近似于带权重的梯度…

步进电机介绍

一、什么是步进电机&#xff1a; 步进电机是一种将电脉冲信号转换成相应角位移或线位移的电动机。每输入一个脉冲信号&#xff0c;转子就转动一个角度或前进一步&#xff0c;其输出的角位移或线位移与输入的脉冲数成正比&#xff0c;转速与脉冲频率成正比。因此&#xff0c;步…

通付盾受邀出席2024安全市场年度大会,荣获“数字安全产业杰出贡献奖”!

1月5日&#xff0c;由国内数字产业独立的第三方调研咨询机构数世咨询主办&#xff0c;以“数字安全&#xff0c;未来可期”为主题的2024安全市场年度大会在北京举办。来自国内网络安全厂商300多人以线上线下方式参加本次大会&#xff0c;通过4个多小时高能演讲&#xff0c;聚焦…

线性代数_同济第七版

contents 前言第1章 行列式1.1 二阶与三阶行列式1.1.1 二元线性方程组与二阶行列所式1.1.2 三阶行列式 1.2 全排列和对换1.2.1 排列及其逆序数1.2.2 对换 1.3 n 阶行列式的定义1.4 行列式的性质1.5 行列式按行&#xff08;列&#xff09;展开1.5.1 引理1.5.2 定理1.5.3 推论 * …

【Vue】项目使用px2rem

使用方法 1.安装包 npm i postcss-px2rem2.编写配置文件 编写核心代码&#xff0c;命名随意&#xff0c;我这里命名为px2rem并放在src/utils文件夹内 // 基准大小 const baseSize 100 // 设置 rem 函数 function setRem() {// 当前页面宽度相对于 1920 宽的缩放比例&#xf…

RK3568平台开发系列讲解(驱动篇)pinctrl 函数操作集结构体讲解

🚀返回专栏总目录 文章目录 一、pinctrl_ops二、pinmux_ops三、pinconf_ops沉淀、分享、成长,让自己和他人都能有所收获!😄 pinctrl_ops:提供有关属于引脚组的引脚的信息。pinmux_ops:选择连接到该引脚的功能。pinconf_ops:设置引脚属性(上拉,下拉,开漏,强度等)。…

安全防御之可信计算技术

可信计算技术是一种计算机安全体系结构&#xff0c;旨在提高计算机系统在面临各种攻击和威胁时的安全性和保密性。它通过包括硬件加密、受限访问以及计算机系统本身的完整性验证等技术手段&#xff0c;确保计算机系统在各种攻击和威胁下保持高度安全和保密性。 一、可信计算基…

WPS Office找回丢失的工作文件

WPS office恢复办公文件方法有两种. 1.通过备份中心可以查看近期编辑 office 历史版本进行恢复. 2.缓存备份目录可以查看编辑过的 office 文件的历史版本&#xff0c;新版本 WPS 可以在配置工具-备份清理找到&#xff0c;2019 年旧版本 WPS 可以在新建任意 office 文件-文件-选…

【Java 设计模式】设计原则之单一职责原则

文章目录 1. 定义2. 好处3. 应用4. 示例结语 在面向对象设计中&#xff0c;单一职责原则是一个重要的设计原则之一。它提倡一个类应该只有一个原因引起变化&#xff0c;即一个类应该只有一个职责。在本文中&#xff0c;我们将深入研究单一职责原则&#xff0c;了解它的定义、优…

有信息搜索、最佳优先搜索、贪心搜索、A_搜索详解

文章目录 【人工智能】— 有信息搜索、最佳优先搜索、贪心搜索、A*搜索无/有信息的搜索Informed Search AlgorithmsBest-first search(最佳优先搜索)Greedy SearchA* Search解释说明A*搜索是代价最优的和完备的对搜索等值线如何理解【人工智能】— 有信息搜索、最佳优先搜索、贪…

异构微服务远程调用如何打jar包

1.服务提供方打 jar 包 RemoteUserService.java package com.finance.system.api;import com.finance.system.api.domain.dto.Enterprise; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.stereotype.Component; import org.springfra…

项目-新闻头条-数据管理平台-ajax综合案例

愿许秋风知我意&#xff0c;解我心中意难平。 项目介绍 项目准备 推荐使用&#xff0c; 每个程序员都有自己的管理方式。 验证码登录 HTML结构&#xff1a; <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><met…

Linux网络的命令和配置

目录 一、网络配置命令 1、配置和管理网络接口 1.1 ifconfig 1.2 ip 1.2.1 ip link 1.2.2 ip addr 1.3 修改网络接口名 1.3.1 临时修改网络接口名 1.3.2 永久修改网络接口名 1.4 永久配置单网卡 1.5 永久配置双网卡 1.6 ethtool 2、查看和设置主机中路由表信息…

国芯科技荣膺高工智能汽车“年度车规MCU高成长供应商”,加速产品精准化系列化布局

2023年12月13—15日&#xff0c;2023&#xff08;第七届&#xff09;高工智能汽车年会在上海召开&#xff0c;大会以“寻找拐点”为主题&#xff0c;通过超80场主题演讲及多场圆桌对话&#xff0c;为智能汽车赛道参与者「备战2024」提供全方位的决策支持。 作为汽车电子芯片领…

基于uniapp封装的card容器 带左右侧两侧标题内容区域

代码 <template><view class"card"><div class"x_flex_header"><div><title v-if"title ! " class"title" :title"title" :num"num"></title></div><div><s…