mysql-server-8.0 在 Ubuntu 20.04 上就地升级失败

mysql-server-8.0 在 Ubuntu 20.04 上就地升级失败

我注意到,当尝试通过 在 Ubuntu Server 20.04 上将 mysql-server-8.0 从 8.0.22 就地升级到 8.0.23 时sudo apt upgrade,它在片刻之后就死机并显示以下输出:

mysqld will log errors to /var/log/mysql/error.log
2021-02-21T06:05:07.442487Z 0 [ERROR] [MY-010946] [Server] Failed to start mysqld daemon. Check mysqld error log.
Warning: Unable to start the server.
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Sun 2021-02-21 06:05:22 UTC; 26ms ago
    Process: 41310 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Process: 41328 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
   Main PID: 41328 (code=exited, status=1/FAILURE)
     Status: "Server upgrade complete"
      Error: 2 (No such file or directory)

Feb 21 06:05:22 astrid systemd[1]: mysql.service: Failed with result 'exit-code'.
Feb 21 06:05:22 astrid systemd[1]: Failed to start MySQL Community Server.
Feb 21 06:05:22 astrid systemd[1]: mysql.service: Scheduled restart job, restart counter is at 1.
Feb 21 06:05:22 astrid systemd[1]: Stopped MySQL Community Server.
Feb 21 06:05:22 astrid systemd[1]: Starting MySQL Community Server...
dpkg: error processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-8.0; however:
  Package mysql-server-8.0 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 mysql-server-8.0
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

我感到困惑,为什么这里报告的状态是“服务器升级完成”,而cat /var/log/mysql/error.log报告的内容如下:

2021-02-21T06:16:27.927806Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23-0ubuntu0.20.04.1) starting as process 44099
2021-02-21T06:16:27.941118Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-02-21T06:16:39.324349Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-02-21T06:16:40.039901Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '127.0.0.1' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2021-02-21T06:16:40.064275Z 4 [System] [MY-013381] [Server] Server upgrade from '80022' to '80023' started.
2021-02-21T06:16:40.144762Z 4 [ERROR] [MY-013178] [Server] Execution of server-side SQL statement '-- Create general_log CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), user_host MEDIUMTEXT NOT NULL, thread_id BIGINT UNSIGNED NOT NULL, server_id INTEGER UNSIGNED NOT NULL, command_type VARCHAR(64) NOT NULL, argument MEDIUMBLOB NOT NULL) engine=CSV CHARACTER SET utf8 comment="General log"; ' failed with error code = 13, error message = 'Can't get stat of './mysql/general_log.CSV' (OS errno 2 - No such file or directory)'.
2021-02-21T06:16:40.148170Z 0 [ERROR] [MY-013380] [Server] Failed to upgrade server.
2021-02-21T06:16:40.149339Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-02-21T06:16:41.024514Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.23-0ubuntu0.20.04.1)  (Ubuntu).
2021-02-21T06:16:41.700252Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23-0ubuntu0.20.04.1) starting as process 44151
2021-02-21T06:16:41.715601Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.

任何帮助是极大的赞赏!

答案1

这是一个非常古老的 MySQL 错误的重复。首先,让我们检查.csv升级脚本所需的文件是否确实存在:

sudo ll {mysql_data_directory}/*.csv

确保将其替换{mysql_data_directory}为您的实际 MySQL 数据目录。如果文件存在,请确认其所有者为mysql。如果不存在,请尝试以下丑陋的黑客攻击:

touch {mysql_data_directory}/mysql.general_log.CSV 
touch {mysql_data_directory}/mysql.slow_log.CSV 

然后重新运行更新。MySQL 将发出类似以下消息:

ERROR 1194 (HY000) at line 719: Table 'general_log' is marked as crashed and should be repaired 
ERROR 1194 (HY000) at line 730: Table 'slow_log' is marked as crashed and should be repaired 
FATAL ERROR: Upgrade failed 

然后启动 MySQL(它会再次抱怨),以 身份连接root,然后像这样修复日志文件:

mysql> repair table general_log; 
mysql> repair table slow_log; 

完成后,重新运行升级。最终更新应该会成功。

相关内容