Mysql

MySQL失敗後如何啟動?

  • January 26, 2022

重新啟動伺服器後,我無法再啟動 mysql。

我遵循了這裡發布的幾個解決方案:

我執行以下命令來啟動服務:

mysql
>> ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
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.
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)
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.

伺服器有 Ubuntu 20.4

關於我能做什麼的任何提示?

我今天遇到了同樣的問題,問題的根源可能不同,但是仔細閱讀/var/log/mysql/error.log它應該指向錯誤。

我刪除了一張我不需要的表格.MYD.MYI文件。這是一個錯誤,我應該刪除表,但我的伺服器的記憶體使用率為 100%。

我所做的是閱讀以下錯誤:

sudo tail -f /var/log/mysql/error.log

保持兩個終端同時打開,先執行

sudo tail -f /var/log/mysql/error.log 

在第一個終端上,然後在第二個終端上執行

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.

對我來說是:

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

我能夠通過添加來修復/etc/mysql/mysql.conf.d/mysqld.cnf

innodb_force_recovery = 2

來自MySQL 文件

如果您能夠以 3 或更低的 innodb_force_recovery 值轉儲您的表,那麼您相對安全,只有損壞的單個頁面上的一些數據會失去。

在此更改之後,我停止並再次啟動 MySQL,它執行良好。

在從@Ergest Basha 調試commens 之後,在檢查日誌之後,它看起來像是一個配置問題:

2022-01-26T15:10:01.855905Z 0

$$ ERROR $$ $$ MY-000077 $$ $$ Server $$/usr/sbin/mysqld:設置值 ‘ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBS> 時出錯 回滾到預設值

引用自:https://dba.stackexchange.com/questions/306615