出现错误:mysql.service 失败,因为控制进程退出并出现错误代码。安装docker后

ioe*_*shu 3 mysql ubuntu docker

我已经在我的 ubuntu 21 系统上安装了 MySQL-server,当我尝试启动 MySQL-Server 时,我得到了Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for details. 安装 docker 并在其上运行 MySQL 之前,我得到 \nit 工作正常

\n

systemctl 状态 mysql.service

\n
mysql.service - MySQL Community Server\n     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:>\n     Active: failed (Result: exit-code) since Sat 2022-01-22 18:32:17 IST; 7min>\n    Process: 19128 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=>\n    Process: 19136 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)\n   Main PID: 19136 (code=exited, status=1/FAILURE)\n     Status: "Server startup in progress"\n      Error: 13 (Permission denied)\n        CPU: 313ms\n\nJan 22 18:32:17 Lenovo systemd[1]: mysql.service: Scheduled restart job, restar>\nJan 22 18:32:17 Lenovo systemd[1]: Stopped MySQL Community Server.\nJan 22 18:32:17 Lenovo systemd[1]: mysql.service: Start request repeated too qu>\nJan 22 18:32:17 Lenovo systemd[1]: mysql.service: Failed with result 'exit-code>\nJan 22 18:32:17 Lenovo systemd[1]: Failed to start MySQL Community Server.\n
Run Code Online (Sandbox Code Playgroud)\n

Journalctl -xeu mysql.service

\n
\xe2\x96\x91\xe2\x96\x91 Subject: A stop job for unit mysql.service has finished\n\xe2\x96\x91\xe2\x96\x91 Defined-By: systemd\n\xe2\x96\x91\xe2\x96\x91 Support: http://www.ubuntu.com/support\n\xe2\x96\x91\xe2\x96\x91 \n\xe2\x96\x91\xe2\x96\x91 A stop job for unit mysql.service has finished.\n\xe2\x96\x91\xe2\x96\x91 \n\xe2\x96\x91\xe2\x96\x91 The job identifier is 6908 and the job result is done.\nJan 22 18:32:17 Lenovo systemd[1]: mysql.service: Start request repeated too qu>\nJan 22 18:32:17 Lenovo systemd[1]: mysql.service: Failed with result 'exit-code>\n\xe2\x96\x91\xe2\x96\x91 Subject: Unit failed\n\xe2\x96\x91\xe2\x96\x91 Defined-By: systemd\n\xe2\x96\x91\xe2\x96\x91 Support: http://www.ubuntu.com/support\n\xe2\x96\x91\xe2\x96\x91 \n\xe2\x96\x91\xe2\x96\x91 The unit mysql.service has entered the 'failed' state with result 'exit-code>\nJan 22 18:32:17 Lenovo systemd[1]: Failed to start MySQL Community Server.\n\xe2\x96\x91\xe2\x96\x91 Subject: A start job for unit mysql.service has failed\n\xe2\x96\x91\xe2\x96\x91 Defined-By: systemd\n\xe2\x96\x91\xe2\x96\x91 Support: http://www.ubuntu.com/support\n\xe2\x96\x91\xe2\x96\x91 \n\xe2\x96\x91\xe2\x96\x91 A start job for unit mysql.service has finished with a failure.\n\xe2\x96\x91\xe2\x96\x91 \n\xe2\x96\x91\xe2\x96\x91 The job identifier is 6908 and the job result is failed.\n
Run Code Online (Sandbox Code Playgroud)\n

小智 14

我尝试了这个并且它有效:

sudo apt autoremove --purge mysql-server\* mariadb-server\*
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql/
sudo mkdir -p /etc/mysql/conf.d
sudo apt install mysql-server
Run Code Online (Sandbox Code Playgroud)

注意:请务必备份您的数据,因为这些命令将删除您的所有MySQL数据。