暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

MySQL8.0.36升级到MySQL8.4.2启动失败处理

原创 董小姐 2024-09-19
452

问题背景

漏洞扫描需要将MySQL8.0.36升级至MySQL8.4.2,升级后启动提示如下报错:

[root@dtweb1 topsoft]# systemctl daemon-reload
[root@dtweb1 topsoft]# systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for
 details.[root@dtweb1 topsoft]# systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 四 2024-09-19 13:52:40 CST; 9s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 34806 ExecStart=/topsoft/mysql842/bin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
 Main PID: 34806 (code=exited, status=1/FAILURE)
   Status: "Server shutdown complete (with return value = 1)"

9月 19 13:52:19 dtweb1 systemd[1]: Starting MySQL Server...
9月 19 13:52:40 dtweb1 systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
9月 19 13:52:40 dtweb1 systemd[1]: Failed to start MySQL Server.
9月 19 13:52:40 dtweb1 systemd[1]: Unit mysqld.service entered failed state.
9月 19 13:52:40 dtweb1 systemd[1]: mysqld.service failed.

分析过程

定位数据库运行日志

[root@dtweb1 topsoft]# cat /etc/my.cnf | grep log
# 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
skip-log-bin
log-error=/var/log/mysqld.log
log_timestamps = system #解决日志中时间和本地差8小时
log_error_suppression_list='MY-013712'

查看数据库运行日志

[root@dtweb1 topsoft]# tail -300f /var/log/mysqld.log
......
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
2024-09-19T13:52:19.463926+08:00 0 [System] [MY-015015] [Server] MySQL Server - start.
2024-09-19T13:52:19.730457+08:00 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the d
efault. Consider not using this option as it' is deprecated and will be removed in a future release.2024-09-19T13:52:19.730621+08:00 0 [System] [MY-010116] [Server] /topsoft/mysql842/bin/mysqld (mysqld 8.4.2) starting as process 34806
2024-09-19T13:52:19.758888+08:00 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-09-19T13:52:22.100167+08:00 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-09-19T13:52:22.232359+08:00 1 [System] [MY-011090] [Server] Data dictionary upgrading from version '80023' to '80300'.
2024-09-19T13:52:23.902199+08:00 1 [System] [MY-013413] [Server] Data dictionary upgrade from version '80023' to '80300' completed.
2024-09-19T13:52:27.553268+08:00 4 [System] [MY-013381] [Server] Server upgrade from '80036' to '80402' started.
2024-09-19T13:52:38.417175+08:00 4 [System] [MY-013381] [Server] Server upgrade from '80036' to '80402' completed.
2024-09-19T13:52:38.663220+08:00 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2024-09-19T13:52:38.663326+08:00 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now sup
ported for this channel.2024-09-19T13:52:38.680615+08:00 0 [ERROR] [MY-000067] [Server] unknown variable 'default_authentication_plugin=mysql_native_password'.
2024-09-19T13:52:38.681942+08:00 0 [ERROR] [MY-010119] [Server] Aborting
2024-09-19T13:52:40.264634+08:00 0 [System] [MY-010910] [Server] /topsoft/mysql842/bin/mysqld: Shutdown complete (mysqld 8.4.2)  MySQL Community
 Server - GPL.2024-09-19T13:52:40.264666+08:00 0 [System] [MY-015016] [Server] MySQL Server - end.

日志中显示未知变量:

ported for this channel.2024-09-19T13:52:38.680615+08:00 0 [ERROR] [MY-000067] [Server] unknown variable 'default_authentication_plugin=mysql_native_password'.

查看配置文件中身份验证插件参数

[root@dtweb1 topsoft]# cat /etc/my.cnf | grep default_authentication_plugin
# Remove leading # to revert to previous value for default_authentication_plugin,
default_authentication_plugin = mysql_native_password

问题原因

从MySQL 8.4.0开始,默认情况下不再启用已弃用的 mysql_native_password 身份验证插件。要启用它,请使用 --mysql-native-password=ON (在MySQL 8.4.0中添加)启动服务器,或者在MySQL配置文件的 [mysqld] 部分中包含 mysql_native_password=ON (在MySQL 8.4.0中添加)。

解决办法

备份配置文件

cp /etc/my.cnf  /etc/my.cnf_bak_20240919

更改身份验证插件

vi /etc/my.cnf

将default_authentication_plugin = mysql_native_password  注释掉,如下:

#default_authentication_plugin = mysql_native_password

增加如下:
mysql-native-password=ON

启动数据库

启动成功

--启动数据库
[root@dtweb1 topsoft]# systemctl start mysqld

--查看状态
root@dtweb1 topsoft]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 四 2024-09-19 13:59:59 CST; 11s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
 Main PID: 108738 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─108738 /topsoft/mysql842/bin/mysqld

9月 19 13:59:54 dtweb1 systemd[1]: Starting MySQL Server...
9月 19 13:59:59 dtweb1 systemd[1]: Started MySQL Server.


「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论