在 Ubuntu 20.04 上安装 mysql 时出现问题

在 Ubuntu 20.04 上安装 mysql 时出现问题

发生的情况是,当执行命令“sudo apt-get install mysql-server”时,它会抛出以下错误:

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Tue 2021-12-28 16:30:45 CST; 6ms ago
    Process: 10525 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)

Dec 28 16:30:45 exatoon27-Inspiron-3558 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 1.
Dec 28 16:30:45 exatoon27-Inspiron-3558 systemd[1]: Stopped MySQL Community Server.
Dec 28 16:30:45 exatoon27-Inspiron-3558 systemd[1]: Starting MySQL Community Server...
Dec 28 16:30:45 exatoon27-Inspiron-3558 mysql-systemd-start[10534]: MySQL system database not found in /var/lib/mysql. Please run mysqld --initialize.
Dec 28 16:30:45 exatoon27-Inspiron-3558 systemd[1]: mysql.service: Control process exited, code=exited, status=1/FAILURE
Dec 28 16:30:45 exatoon27-Inspiron-3558 systemd[1]: mysql.service: Failed with result 'exit-code'.
Dec 28 16:30:45 exatoon27-Inspiron-3558 systemd[1]: Failed to start 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)

值得注意的是,我已经按照以下顺序尝试了以下内容:

sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade
sudo apt-get install mysql-server

相关内容