Can't start MySQL server (database corruption)
Solution 1:
I successfully recovered the data by editing /etc/mysql/my.cnf
(depending on your configuration, my.cnf
may have a different location) by adding:
[mysqld]
innodb_force_recovery = 1
And then running:
sudo systemctl start mysql
It didn't work for the first time and I incremented the number to 2
, 3
etc, retrying to start after each configuration update. Eventually it started.
Then I just I just commented out the innodb_force_recovery
stuff and it restarted successfully (some operations are not allowed in the force recovery mode).
This answer was very helpful.
Solution 2:
I tried everything written above, but nothing worked for me until I dared to try the next thing, which is based on the opposite idea
/etc/init.d/mysql stop
service mysql stop
killall -KILL mysql mysqld_safe mysqld
/etc/init.d/mysql start
service mysql start