MySQL失败后如何启动?

Jav*_*i M 7 mysql authentication

重新启动服务器后,我无法再启动 mysql。

我遵循了这里发布的几个解决方案:

我运行以下命令来启动该服务:

mysql
>> ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Run Code Online (Sandbox Code Playgroud)
sudo service mysql start
>> Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
Run Code Online (Sandbox Code Playgroud)
systemctl status mysql.service
>> mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2022-01-26 15:18:33 UTC; 47s ago
    Process: 2612 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Run Code Online (Sandbox Code Playgroud)
 journalctl -xe
>> Startup of the manager took 379405 microseconds.
Jan 26 14:33:24 sumentserver polkit-agent-helper-1[2223]: pam_unix(polkit-1:auth): authentication failure; logname= uid=1001 euid=0 tty= >
-- Reboot --
Jan 26 14:44:33 sumentserver systemd[1685]: Reached target Paths.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit UNIT has finished successfully.
Run Code Online (Sandbox Code Playgroud)

服务器有Ubuntu 20.4

关于我能做什么有什么建议吗?

Erg*_*sha 3

我今天遇到了同样的问题,问题的根源可能不同,但是仔细阅读/var/log/mysql/error.log它应该指出错误。

我删除了一张不需要的表.MYD.MYI文件。这是一个错误,我应该删除该表,但我的服务器内存使用率为 100%。

我所做的是阅读以下错误:

sudo tail -f /var/log/mysql/error.log
Run Code Online (Sandbox Code Playgroud)

保持两个终端同时打开,先运行

sudo tail -f /var/log/mysql/error.log 
Run Code Online (Sandbox Code Playgroud)

在第一个终端上运行,然后在第二个终端上运行

sudo systemctl stop mysql.service   ---to shut it down
sudo systemctl start mysql.service  ---to try and start up and see the reason why it is not starting.
Run Code Online (Sandbox Code Playgroud)

对我来说是:

2022-01-26T16:30:36.213788Z 0 [Note] InnoDB: Database was not shutdown normally!
2022-01-26T16:30:36.213802Z 0 [Note] InnoDB: Starting crash recovery.
2022-01-26T16:30:36.213830Z 0 [ERROR] InnoDB: Tablespace 605 was not found at ./contratti/ip_log2_bak.ibd.
2022-01-26T16:30:36.213840Z 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace.
2022-01-26T16:30:36.644359Z 0 [ERROR] InnoDB: Cannot continue operation.
2022-01-26T16:30:38.045091Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-01-26T16:30:38.062994Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.34-log) starting as process 2843 ...
2022-01-26T16:30:38.416074Z 0 [Note] InnoDB: PUNCH HOLE support available
Run Code Online (Sandbox Code Playgroud)

我能够通过添加来修复/etc/mysql/mysql.conf.d/mysqld.cnf

innodb_force_recovery = 2
Run Code Online (Sandbox Code Playgroud)

来自MySQL 文档

如果您能够转储 innodb_force_recovery 值为 3 或更低的表,那么您相对安全,只有损坏的单个页面上的部分数据会丢失。

进行此更改后,我停止并重新启动 MySQL,它工作得很好。