MySQL
MySQL高可用配置
MySQL Slave状态参数详解
基于二进制日志文件的复制
使用全局事务标识符GTID复制
MySQL安装升级
MySQL RPM包安装参考
MySQL编译化安装参考
MySQL Server版本升级
MySQL 操作手册/说明
MySQL导入导出操作
库,表,字段的字符集修改方法
根据字段生成自定义SQL语句
MySQL查询流程概述
MySQL 常用脚本
MySQL数据库冷备脚本
MySQL内存占用分析
MySQL内存消耗分析
检查MySQL引起的高内存占用
InnoDB下的内存分析和优化计算
MySQL常见问题
MySQL告警:Aborted connection日志的分析
MySQL使用命令kill进程后出现killed死锁问题
从库重起初始化relaylog失败
安全插件Connection-Control导致无法登录的问题
MySQL性能优化
MySQL查询慢性能分析
本文档使用 MrDoc 发布
-
+
home page
MySQL Server版本升级
>说明: 基于安全等保或业务迭代需要,需要对MySQL数据库版本进行迭代升级时,可参考此文档 测试环境:CentOS 7.6 当前数据库:MySQL v5.7.10 目标数据库:MySQL v5.7.36 # 编译新版数据库 步骤:略... 参考文档地址:https://wiki.netimed.cn/project-5/doc-29/ # 升级步骤 ## 停止运行服务 步骤:略... 停止运行所有和数据库进行连接,并且可写入数据的服务,示例:java,tomcat,php等 ## 停止数据库运行 `CentOS`: ```bash service mysql stop # 或 systemctl stop mysqld ``` ## 备份数据 通过`cp -rp` 指令对数据进行全量备份,也可进一步压缩 **相关指令:** ```bash cp -rp OriMysqlDataPath OriMysqlDataPath_bak tar -cvf OriMysqlDataPath_bef.tar OriMysqlDataPath ``` 其中: - `OriMysqlDataPath`为原始数据库数据目录 - `OriMysqlDataPath_bak`为备份后的目录 - `OriMysqlDataPath_bef.tar`为打包备份后的文件名称 ## 启动并更新数据库 启动数据库 ```bash [root@localhost logs]# systemctl start mysqld [root@localhost logs]# systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2022-06-13 18:11:02 CST; 27min ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Main PID: 10841 (mysqld) CGroup: /system.slice/mysqld.service └─10841 /data/mysql/basedir/bin/mysqld --defaults-file=/data/mysql/basedir/etc/my.cnf Jun 13 18:11:02 upload_hrs_sql systemd[1]: Started MySQL Server. ``` 成功启动后,查看日志会打印报错: ``` 2022-06-13T10:11:03.753102Z 0 [Note] Server socket created on IP: '0.0.0.0'. 2022-06-13T10:11:03.760317Z 0 [Note] Failed to start slave threads for channel '' 2022-06-13T10:11:03.763938Z 0 [ERROR] Incorrect definition of table performance_schema.replication_connection_status: expected column 'RECEIVED_TRANSACTION_SET' at position 7 to have type longtext, found type text. 2022-06-13T10:11:03.764236Z 0 [ERROR] Incorrect definition of table performance_schema.replication_group_member_stats: expected column 'COUNT_TRANSACTIONS_ROWS_VALIDATING' at position 6, found 'COUNT_TRANSACTIONS_VALIDATING'. 2022-06-13T10:11:03.765091Z 0 [Note] Event Scheduler: Loaded 0 events 2022-06-13T10:11:03.765312Z 0 [Note] /data/mysql/basedir/bin/mysqld: ready for connections. Version: '5.7.36-log' socket: '/data/mysql/tmp/mysql.sock' port: 3306 Source distribution 2022-06-13T10:14:37.425239Z 5 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name. Please run mysql_upgrade 2022-06-13T10:14:37.425264Z 5 [Warning] InnoDB: Table mysql/innodb_index_stats has length mismatch in the column name table_name. Please run mysql_upgrade [root@localhost logs]# ``` 其中的`[ERROR]`和`[Warning]`级别日志内容均表示版本升级后需要对数据库进行更新操作 更新指令如下: ```bash [root@localhost logs]# /data/mysql/basedir/bin/mysql_upgrade -uroot -p Enter password: Checking if update is needed. Checking server version. Running queries to upgrade MySQL server. Checking system database. mysql.columns_priv OK mysql.db OK mysql.engine_cost OK ... mysql.time_zone_transition_type OK mysql.user OK Found outdated sys schema version 1.5.0. Upgrading the sys schema. Checking databases. ... ``` 更新完毕后重启数据库 ```bash systemctl restart mysqld ``` 再次启动后,查看日志,无新增报错则表示执行完成
Nathan
June 13, 2022, 7:33 p.m.
转发文档
Collection documents
Last
Next
手机扫码
Copy link
手机扫一扫转发分享
Copy link
Markdown文件
PDF文件
Docx文件
share
link
type
password
Update password