Mysql Check/Repair Database

Check a Specific Table in a Database

If your application gives an error message saying that a specific table is corrupted, execute the mysqlcheck command to check that one table.

The following are some of the key options that you can use along with mysqlcheck.

  • -A, –all-databases Consider all the databases
  • -a, –analyze Analyze tables
  • -1, –all-in-1 Use one query per database with tables listed in a comma separated way
  • –auto-repair Repair the table automatically it if is corrupted
  • -c, –check Check table errors
  • -C, –check-only-changed Check tables that are changed since last check
  • -g, –check-upgrade Check for version dependent changes in the tables
  • -B, –databases Check more than one databases
  • -F, –fast Check tables that are not closed properly
  • –fix-db-names Fix DB names
  • –fix-table-names Fix table names
  • -f, –force Continue even when there is an error
  • -e, –extended Perform extended check on a table. This will take a long time to execute.
  • -m, –medium-check Faster than extended check option, but does most checks
  • -o, –optimize Optimize tables
  • -q, –quick Faster than medium check option
  • -r, –repair Fix the table corruption

-c check
-o optimize
-r reapir
-a analyze

For a Single database with all tables. The database name is “a026913f_gdy4rcc”

mysqlcheck -c database_name  -u database user -p
Enter password:
a026913f_gdy4rcc.admin_adobe_ims_webapi OK
a026913f_gdy4rcc.admin_analytics_usage_version_log OK
a026913f_gdy4rcc.admin_passwords OK
a026913f_gdy4rcc.admin_system_messages OK
a026913f_gdy4rcc.admin_user OK
a026913f_gdy4rcc.admin_user_expiration OK
a026913f_gdy4rcc.admin_user_session OK
a026913f_gdy4rcc.adminnotification_inbox OK
a026913f_gdy4rcc.adobe_stock_asset OK
a026913f_gdy4rcc.adobe_stock_category OK
a026913f_gdy4rcc.adobe_stock_creator OK
a026913f_gdy4rcc.adobe_user_profile OK
a026913f_gdy4rcc.authorization_role OK
a026913f_gdy4rcc.authorization_rule OK
a026913f_gdy4rcc.braintree_credit_prices OK
a026913f_gdy4rcc.braintree_transaction_details OK
a026913f_gdy4rcc.cache OK
a026913f_gdy4rcc.cache_tag OK
a026913f_gdy4rcc.captcha_log OK
a026913f_gdy4rcc.catalog_category_entity OK
a026913f_gdy4rcc.catalog_category_entity_datetime OK
a026913f_gdy4rcc.catalog_category_entity_decimal OK
a026913f_gdy4rcc.catalog_category_entity_int OK
a026913f_gdy4rcc.catalog_category_entity_text OK
a026913f_gdy4rcc.catalog_category_entity_varchar OK
a026913f_gdy4rcc.catalog_category_product OK
a026913f_gdy4rcc.catalog_category_product_index OK
a026913f_gdy4rcc.catalog_category_product_index_replica OK
a026913f_gdy4rcc.catalog_category_product_index_store1 OK
a026913f_gdy4rcc.catalog_category_product_index_store1_replica OK

.....

For Plesk

Login to mysql on Plesk

[root@austin ~]# mysql -uadmin -p`cat /etc/psa/.psa.shadow`

Check a single table in a database on linux server without plesk

[root@austin ~]# mysqlcheck -c database_name table -u root -p

[stextbox id=”alert” defcaption=”true” mode=”css”]For Plesk[/stextbox]

For repairing a single table

[root@austin ~]# mysqlcheck -r database_name table_name -uadmin -p`cat /etc/psa/.psa.shadow`

Here is the command to run to repair all tables in a database.

[root@austin ~]# mysqlcheck -r database_name -uadmin -p`cat /etc/psa/.psa.shadow`

Here is the command to run for all databases and tables

[root@austin ~]# mysqlcheck --all-databases -u admin -p`cat /etc/psa/.psa.shadow` --auto-repair

For cPanel

# mysqlcheck --all-databases -r #repair
# mysqlcheck --all-databases -a #analyze
# mysqlcheck --all-databases -o #optimize

Simple:


# mysql -u username -p databasename
# password: ********
mysql> check table tablename;
mysql> repair table tablename;

cPanel

In cPanel, you can repair a database table by:

cPanel -> Databases -> MySQL Databases

You may need to go to Page 2, so under Current Databases [2] or >> to go to the next page. Under Modify Databases click [Check DB] or [Repair DB].

Plesk

Open the database in phpMyAdmin. To do that, go to your Plesk control panel, click “Websites and Domains,” click “Databases,” and then click the database in question. From there, click “Webadmin” under “Tools.” You will most likely be presented with phpMyAdmin.

Next, click “Databases” in the upper right, click the database name, then scroll all the way down and click “Check All” to check all the tables. From the drop down menu, select “Check Tables” and your tables will immediately be checked. After that, you can decide which tables to select and choose “repair” from the drop down menu

Leave a Comment