所以最近我重新安装目录后开始出现新的错误,/etc/mysql
在我使用显示的过程重新安装目录后,该目录看起来正确这里,我使用了“恢复已删除的目录”方法。现在我在启动 MySQL 服务器本身时遇到了问题,我不想卸载或重新安装数据库,因为我害怕丢失文件。我将提供所有必要的详细信息,以尝试以安全的方法解决此问题。
错误详情:
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 2019-12-21 16:59:38 EST; 5ms ago
Process: 3942 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 3941 ExecStart=/usr/sbin/mysqld (code=exited, status=2)
Process: 3933 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 3941 (code=exited, status=2)
Dec 21 16:59:38 ns529730 systemd[1]: Failed to start MySQL Community Server.
Dec 21 16:59:38 ns529730 systemd[1]: mysql.service: Unit entered failed state.
Dec 21 16:59:38 ns529730 systemd[1]: mysql.service: Failed with result 'exit-code'.
dpkg: error processing package mysql-server-5.7 (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
mysql-server-5.7
E: Sub-process /usr/bin/dpkg returned an error code (1)
systemctl status 命令显示:
root@ns529730:~# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Sat 2019-12-21 17:10:40 EST; 14s ago
Process: 6727 ExecStart=/usr/sbin/mysqld (code=exited, status=2)
Process: 6720 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 6727 (code=exited, status=2); : 6728 (mysql-systemd-s)
Memory: 15.0M
CPU: 327ms
CGroup: /system.slice/mysql.service
└─control
├─6728 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─6784 mysqladmin ping
Dec 21 17:10:40 ns529730 systemd[1]: Starting MySQL Community Server...
Dec 21 17:10:41 ns529730 systemd[1]: mysql.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
系统:Ubuntu 16.04 MySQL版本:5.7
答案1
好的,我通过innodb_force_recovery = 1
在mysqld.cnf
文件中的 [mysqld] 下添加来修复了这个问题。您可以尝试从 1 到 10 的数字,因为第一次使用时可能不起作用。对于使用旧 mysql 版本的人来说,您应该在主配置文件上执行此操作,因为旧版本中有配置文件,etc/mysql/my.cnf
但 5.7 mysql 版本中有配置文件etc/mysql/mysql.conf.d/mysqld.cnf
。答案来自这里完成编辑后,尝试使用以下方法启动 mysql 服务器sudo systemctl start mysql