8

I had InnoDB corruption and managed to start the server in read only mode and perform a fresh backup using innodb_force_recovery=5.

This way of starting the service puts the databases in read only mode, even deletion is disallowed.

Is there an official procedure to reset the whole server into a fresh installed (or at least "empty") version?

And in case there isn't, then what are the correct uninstall/reinstall steps to make sure there will be no remaining residues of data that could generate problems in the future?

1 Answers1

8

MariaDB can be reverted to the fresh state by removing its data files.

Say if you run MariaDB on a Debian you can do the next:

systemctl stop mysql
rm -rf /var/lib/mysql/*
systemctl start mysql

At the start if no datafiles exists MariaDB will recreate the internal scheme mysql.* with all default values. All leftovers like config and log files you have to clean up by hands.

Kondybas
  • 4,323
  • 15
  • 13
  • 7
    Maybe this is different on Debian, but I think you have to run mysql_install_db before you start it up again - at least that is my experience on Redhat/Fedora/CentOS. – dbdemon Mar 15 '20 at 12:58
  • 1
    @dbdemon On debian and freebsd (at least) start scripts invoke it automatically if no system db was found at datadir – Kondybas Mar 15 '20 at 14:59
  • 1
    My Debain 11 did not automatically invoke mysql_install_db . It is easy enough to check: ls /var/lib/mysql/mysql . If there is no directory it didn't run. – Ron Piggott Dec 06 '21 at 00:55
  • 2
    On debian 10, I called /var/lib/dpkg/info/mariadb-server-10.3.postinst configure to recreate "mysql" database – Pascal Pixel Rigaux Jul 01 '22 at 08:01
  • Thanks @dbdemon -- I forgot about mysql_install_db and MariaDB didn't want to start on macOS for me. After running the command it went on fine. – dimitarvp Jan 05 '24 at 19:53