MariaDB won't start after server crash. No error logs

After several days I was able to fix it without any data loss. As I suspected, there was no data loss from the outage. I did many things to try to fix the issue but here is what I believe fixed it:

I renamed my /var/lib/mysql folder to make sure I had a backup, then I deleted my /etc/my.cnf file. I reinstalled mariadb and mariadb-server then started it up. From there I copied my backed-up /var/lib/mysql folder back in and in my /etc/my.cnf added the following lines (gotten from here):

port = 8881
innodb_force_recovery=3
innodb_purge_threads=0

(I think I actually used recovery mode 4 but 3 would have worked for me too)

From there I was able to start up MariaDB with all of my databases. I then ran mysqlcheck --all-databases -p to find that none of my databases had been corrupted. From here, I was unable to get MariaDB to successfully stop, and then I had issues starting it up again, so I repeated the process of deleting the /var/lib/mysql/ folder and running the database installation so that I could copy my backup back in.

From there I started MariaDB with InnoDB forced recovery and once it was running I dumped everything using the command mysqldump -u root -p --all-databases > alldb.sql. I then force stopped MariaDB as it wouldn't stop properly, then rebooted. I uninstalled MariaDB, deleted my /var/lib/mysql/, and renamed my /etc/my.cnf, then reinstalled MariaDB. Once I got it running fresh, I imported my dumped databases using mysql -u root -p < alldb.sql and flushed privileges in the MySQL shell using FLUSH PRIVILEGES; and everything is working great now with no data loss.

As I am running CentOS, I had to do some SELinux stuff along the way. I mostly just followed what the pop-up diagnostics dialogue said to do, then reran the SELinux commands I did originally when installing my Nextcloud server in the first place to get all of the permissions right.


Looks like the database storage has become corrupted. Restore from backup, and put a big sign on your hard drives, "do not unplug whilst running".