After a hardware failure, after 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 ok. MariaDB includes several utilities to do this.
The mysqlcheck
program can check, analyze, optimize, and repair 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 of our databases with the --all-databases
option, as follows:
mysqlcheck -u root -p --all-databases
By default, mysqlcheck
will only check tables...