Repairing MariaDB
After a hardware failure, a power outage, or even after an upgrade, it is a good idea to check the tables in our MariaDB databases to make sure they are all right. MariaDB includes several utilities for doing this.
Checking and optimizing tables with mysqlcheck
The mysqlcheck
program can check, analyze, optimize, and repair the MariaDB database tables. Basic syntax for the command is as follows:
mysqlcheck [options] [-u username] [-p] database_name [table_name]
Here is an example of running the command to check our test database, and its output:
daniel@gandalf:~$ mysqlcheck -u root -p test Enter password: test.employees OK
We can specify multiple databases using the --databases
option as follows:
mysqlcheck -u root -p --databases db_name1 db_name2 db_name3
We can also tell the program to check all our databases with the --all-databases
option, as follows:
mysqlcheck -u root -p --all-databases
By default, mysqlcheck
will only perform basic...