Ubuntu 20.04.1 LTS - MySQL 错误 - 未配置/依赖性错误

Ubuntu 20.04.1 LTS - MySQL 错误 - 未配置/依赖性错误

我对 Ubuntu 有点菜鸟。我试图在我的系统(Ubuntu 20.04.1 LTS)上安装一个程序并更新一些程序,但我一直收到 MySQL 错误。我有点不明白这一切意味着什么:

update-alternatives: using /var/lib/mecab/dic/ipadic-utf8 to provide /var/lib/me
cab/dic/debian (mecab-dictionary) in auto mode
Setting up mysql-server-8.0 (8.0.22-0ubuntu0.20.04.3) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my
.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
mysqld will log errors to /var/log/mysql/error.log
2020-12-05T10:59:07.377235Z 0 [ERROR] [MY-010946] [Server] Failed to start mysql
d daemon. Check mysqld error log.
Warning: Unable to start the server.
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib
/systemd/system/mysql.service.
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 Sat 2020-12-05 
10:59:10 GMT; 10ms ago
    Process: 67472 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=e
xited, status=0/SUCCESS)
    Process: 67480 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
   Main PID: 67480 (code=exited, status=1/FAILURE)
     Status: "Data Dictionary upgrade from MySQL 5.7 in progress"
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 it's a follow-up er
ror from a previous failure.
                            Processing triggers for systemd (245.4-4ubuntu3.3) .
..
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for libc-bin (2.31-0ubuntu9.1) ...
Errors were encountered while processing:
 mysql-server-8.0
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

任何帮助将非常感激。

答案1

该错误消息似乎是一个很好的起点:

Status: "Data Dictionary upgrade from MySQL 5.7 in progress"
dpkg: error processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned
 error exit status 1

如果您最近从 MySQL 5.7 升级到 8.0,则需要对系统数据库进行大量更新。升级脚本因某种原因失败。

最容易解决方案 — 只要您备份了重要的数据库或根本不需要它们 — 就是完全删除 MySQL,然后重新安装。5.7 和 8.0 之间发生了很多变化,因此全新安装可能会为您解决此问题。

要完全删除 MySQL,请按照以下步骤操作:

  1. sudo apt-get remove --purge mysql*
  2. sudo apt-get purge mysql*
  3. sudo apt-get autoremove
  4. sudo apt-get autoclean
  5. sudo apt-get remove dbconfig-mysql

确保数据目录消失可能也是一个好主意。

  1. 检查是否/var/lib/mysql存在,如果存在,则执行(2)
  2. sudo rm -Rf /var/lib/mysql

从那里你可以重新安装 MySQL:

  1. sudo apt install mysql-server
  2. sudo mysql_secure_installation
  3. (可选)恢复数据库和用户帐户

希望这可以帮助

相关内容