GoAdmio

repair

Repair the tables of one MySQL/MariaDB database, or of all databases

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also


Overview

/go/repair runs mysqlcheck --repair on a database to fix corrupted tables. It:

Run it when a site shows errors such as Table './db/table' is marked as crashed.

[!WARNING] A repair can discard rows that cannot be recovered. Back up the database first with mysqlbackup or backup.


Quick start

# Repair every table in one database
/go/repair mydb

Syntax

/go/repair <database>
/go/repair all

The command takes one argument and has no -- options. Only the first argument is read.


Arguments

Argument Effect
<database> Repairs every table in that database, in the foreground.
all Repairs every database on the server, in a detached screen session named RepairAll. See the warning below.
(none) mysqlcheck prints its usage text and repairs nothing.

[!WARNING] As written, /go/repair all starts the screen session without passing all to it. The session then runs with no database name and repairs nothing. To repair all databases, start a screen session yourself and run the command inside it (see Examples).


Output

The command prints what mysqlcheck reports, one entry per table. The exact wording depends on your MariaDB version.

mydb.wp_posts                                      OK
mydb.wp_options                                    OK
Result Meaning
OK The table is healthy, or was repaired.
The storage engine for the table doesn't support repair The table uses a storage engine that cannot be repaired this way, such as InnoDB.
An error line The table could not be repaired.

With all, nothing is printed in your terminal. The work happens in the detached session.


Examples

# Repair one database
/go/repair mydb
# Repair all databases: start a screen session, then run the command inside it
screen -S RepairAll
/go/repair all
# Detach with Ctrl+A then D, and reattach later with:
screen -r RepairAll
# List screen sessions
screen -ls
# Review the log of past runs
tail -n 20 /var/log/go/repair.log

Troubleshooting

Symptom Likely cause Fix
mysqlcheck prints usage text No database name was given. Pass a database name, for example /go/repair mydb.
/go/repair all returns at once and nothing is repaired The detached session is started without the all argument. Run it inside your own screen session. See Examples.
screen: command not found screen is not installed. Install screen, or run the command inside another terminal session.
Access denied for user 'root' The password in the GoAdmio configuration is missing or wrong. Check DBPass in /usr/local/goadmio/include/config/config.php.
Unknown database The name is misspelled. List the databases with dbls.
The storage engine for the table doesn't support repair The table is InnoDB. Restore the table from a backup. See Storage engines.
The command seems stuck on all A large table is being repaired. Reattach with screen -r RepairAll to watch progress.

Details

Where the password comes from

The command reads DBPass from /usr/local/goadmio/include/config/config.php and uses it as the MariaDB root password.

[!WARNING] The password is passed to mysqlcheck on the command line, so it can be visible in the process list while the command runs.

What it runs

Mode Command
One database mysqlcheck -uroot -p<password> -r <database>
All databases mysqlcheck -uroot -p<password> --repair --all-databases

-r is the short form of --repair.

Storage engines

mysqlcheck --repair can repair MyISAM, Aria, ARCHIVE, and CSV tables. It cannot repair InnoDB tables, which recover from crashes by themselves when MariaDB starts. If an InnoDB table is damaged, restore it from a backup.

To change the engine of tables, see myisam2innodb and myisam2aria.

The all mode

When run with all outside a screen session, the command replaces itself with screen -dm -S RepairAll /bin/bash <script>. The session is detached, and the command returns at once. Inside a screen session, all runs in the foreground.

Logging

Every run appends its arguments with a timestamp to /var/log/go/repair.log.

What a run does

flowchart TD
    A["repair name"] --> B["Read root password from config.php"]
    B --> C{"name is all?"}
    C -- "No" --> D["mysqlcheck -r name"]
    C -- "Yes" --> E{"Inside screen?"}
    E -- "Yes" --> F["mysqlcheck --repair --all-databases"]
    E -- "No" --> G["Start detached screen session RepairAll"]

See also

Command Description
dbls List all databases and their sizes
mysqlbackup Back up MariaDB/MySQL to a remote server via rsync
backup Create a backup for all GoAdmio accounts (local and remote)
myisam2innodb Convert MariaDB/MySQL tables from MyISAM to InnoDB
myisam2aria Convert MariaDB/MySQL tables from MyISAM to Aria
my Optimize the my.cnf configuration for MySQL/MariaDB