brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wp db check tests every WordPress table for corruption

WordPress
~/tips/tip-wordpress-wp-db-check

wp db check

Runs a table check on the whole WordPress database using the credentials from wp-config.php.

A site that shows odd errors after a crash or a full disk may have a damaged table. WP-CLI can check them all in one command.

wp db check

The command runs the mysqlcheck utility with the --check option, using the database credentials from wp-config.php. You see one line per table, and at the end a success message when the checks passed.

It is a read-only check, so it is a safe first step. If it reports a problem, the neighbours are wp db repair, which runs mysqlcheck with repair, and wp db optimize, which runs it with optimize.

wp db export backup-before-repair.sql
wp db repair

Export a backup before you repair anything, because a repair is not something you can undo.

You can also use wp db query with a CHECK TABLE statement for specific tables, which prints a status per table.

The caveat is the storage engine. The check and repair features depend on what MySQL or MariaDB supports for the engine of each table, and a clean result does not mean the content is correct, only that the table structure is healthy. A broken plugin will not show up here.

Further reading: WP-CLI: wp db check, WP-CLI: wp db repair

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link