![在 Ubuntu 20.04 上安装 mysql 时出现问题](https://linux22.com/image/943634/%E5%9C%A8%20Ubuntu%2020.04%20%E4%B8%8A%E5%AE%89%E8%A3%85%20mysql%20%E6%97%B6%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98.png)
发生的情况是,当执行命令“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