环境说明
mysql8.0.28 升级至最新版本,安装在(/data/mysql)
下载最新的mysql :mysql-8.0.35-linux-glibc2.12-x86_64.tar.xz
升级步骤
1 停止mysql 服务
2 备份数据库及my.cnf 此处使用物理拷贝: /data/mysql目录
3 解压tar -xvf mysql-8.0.35-linux-glibc2.12-x86_64.tar.xz 覆盖目录/data/mysql/install
[]# mkdir install_8.0.28
[]# mv /data/mysql/install/* /data/mysql/install_8.0.28/
[]# mv /data/mysql/mysql-8.0.35-linux-glibc2.12-x86_64/* /data/mysql/install/
修改权限:
chown -R mysql.mysql /data/mysql
4 使用新版本的二进制文件启动MySQL服务,检查mysql服务状态及错误日志 (mysql5.x使用MySQL提供的工具 mysql_upgrade -u root -p ,升级数据库;8.0版本修复用户表是自动完成的 升级后不需要重新启动)
su - mysql -c "/data/mysql/install/bin/mysqld_safe --defaults-file=/data/mysql/conf/my.cnf &"
2023-11-08T07:23:59.287338Z mysqld_safe Logging to '/data/mysql/logs/error.log'. 2023-11-08T07:23:59.407633Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/data
ps aux|grep mysql
mysql 错误日志:
tail -2000f /data/mysql/logs/error.log
Upgrading redo log: 0M, LSN=83144362551.
...
[Note] [MY-013327] [Server] MySQL server upgrading from version '80028' to '80035'.
...
[Note] [MY-014065] [Server] Upgrading information schema from version 80023 to 80030.
[Note] [MY-014066] [Server] Upgrading performance schema from version 80028 to 80033.
[System] [MY-013381] [Server] Server upgrade from '80028' to '80035' started.
[Note] [MY-013386] [Server] Running queries to upgrade MySQL server.
...
[Note] [MY-013387] [Server] Upgrading system table data.
[Note] [MY-013385] [Server] Upgrading the sys schema.
[Note] [MY-013400] [Server] Upgrade of help tables started.
[Note] [MY-013400] [Server] Upgrade of help tables completed.
[Note] [MY-013394] [Server] Checking 'mysql' schema.
[Note] [MY-013394] [Server] Checking 'sys' schema.
[System] [MY-013381] [Server] Server upgrade from '80028' to '80035' completed.
补充内容:
mysql8.0小版本升级中修复用户表是自动完成的,使用mysql_upgrade -u root -p有如下提示:
[~]# /data/mysql/install/bin/mysql_upgrade -S /data/mysql/tmp/mysql.sock -uroot -p
The mysql_upgrade client is now deprecated. The actions executed by the upgrade client are now done by the server. To upgrade, please start the new MySQL binary with the older data directory. Repairing user tables is done automatically. Restart is not required after upgrade. The upgrade process automatically starts on running a new MySQL binary with an older data directory. To avoid accidental upgrades, please use the --upgrade=NONE option with the MySQL binary. The option --upgrade=FORCE is also provided to run the server upgrade sequence on demand. It may be possible that the server upgrade fails due to a number of reasons. In that case, the upgrade sequence will run again during the next MySQL server start. If the server upgrade fails repeatedly, the server can be started with the --upgrade=MINIMAL option to start the server without executing the upgrade sequence, thus allowing users to manually rectify the problem.
百度翻译如下:
mysql_upgrade客户端现在已被弃用。升级客户端执行的操作现在由服务器完成。
要升级,请使用旧的数据目录启动新的MySQL二进制文件。修复用户表是自动完成的。升级后不需要重新启动。
升级过程会在使用旧的数据目录运行新的MySQL二进制文件时自动开始。为了避免意外升级,请在MySQL二进制文件中使用--upgrade=NONE选项。还提供了选项--upgrade=FORCE,用于根据需要运行服务器升级序列。
服务器升级可能由于多种原因而失败。在这种情况下,升级序列将在下一次MySQL服务器启动时再次运行。如果服务器升级重复失败,可以使用--upgrade=MINIMAL选项启动服务器,无需执行升级序列即可启动服务器,从而允许用户手动更正问题。




