• silverinkandstardust

    (@silverinkandstardust)


    Hi, recently my client and I tried to access their website online. When we tried to open the website, we received the message “Error Establishing a Database Connection”. When this happened I decided to check the website through the admin, there i got the message “One or more database files are unavailable”. I followed the steps to repair the database by accessing the file manager on my host website HostGator. I opened the wp-config file and added define(‘WP_ALLOW_REPAIR’, true);. I then saved the file and went to the admin repair page when I got there I got the message this message:

    The wp_users table is okay.

    The wp_usermeta table is okay.

    The wp_posts table is okay.

    The wp_comments table is okay.

    The wp_links table is okay.

    The wp_options table is not okay. It is reporting the following error: Table is marked as crashed. WordPress will attempt to repair this table…
        Failed to repair the wp_options table. Error: Number of rows changed from 971 to 969

    The wp_postmeta table is not okay. It is reporting the following error: 3 clients are using or haven't closed the table properly. WordPress will attempt to repair this table…
        Successfully repaired the wp_postmeta table.

    The wp_terms table is okay.

    The wp_term_taxonomy table is okay.

    The wp_term_relationships table is okay.

    The wp_termmeta table is okay.

    The wp_commentmeta table is okay.

    Some database problems could not be repaired. Please copy-and-paste the following list of errors to the WordPress support forums to get additional assistance.

    wp_options: Number of rows changed from 971 to 969

    How do I repair the database problem “wp_options: Number of rows changed from 971 to 969”?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @silverinkandstardust

    Sorry to hear you are facing this issue.

    Do you have access to PHPmyAdmin?

    Can you try the following queries ?

    CHECK TABLE wp_options;

    Then

    REPAIR TABLE wp_options;
    CHECK TABLE wp_options;

    Is it using MyISAM or InnoDB, if MyISAM, try

    ALTER TABLE wp_options ENGINE=InnoDB;

    Let us know the result you get
    Best Regards
    Patrick Freitas

    Hi @silverinkandstardust,Before running anything else on that table, please make a full backup of the database first, and check whether HostGator has a recent automatic backup you can restore from. That matters here because the repair already dropped two rows, from 971 to 969, so two options were lost and a repair alone cannot bring them back. If a backup from before the crash is available, restoring the wp_options table from it is the cleanest fix.If there is no usable backup, then Patrick’s suggestion is the right next step: in phpMyAdmin, run CHECK TABLE wp_options, then REPAIR TABLE wp_options, and check the result again. Only change the table engine if it is still MyISAM and the repair still fails, and make a backup before that change too.Once the table reports as OK, remove the WP_ALLOW_REPAIR line from wp-config.php, then check the site carefully. Those two lost rows were probably a plugin or theme setting, so you may need to re-save a setting or two in the dashboard to get everything back to normal.

    jimrohan

    (@jimrohan)

    Hi silverinkandstardust,

    That “Number of rows changed from 971 to 969” message looks alarming, but it is actually telling you what the repair did, so let me explain it in plain terms. 🙂

    Your wp_options table uses the older MyISAM format, and it crashed while MySQL was writing to it. When the repair rebuilt the table, it could not recover 2 of the 971 rows, so it dropped them and the table now has 969 rows. The table can usually be used again after that, but those 2 rows are gone for good unless you have a backup that contains them.

    In most cases the lost rows are expired temporary entries, called transients, that WordPress and plugins recreate on their own, so the site often keeps working normally. But a lost row can also be a real setting, so it is worth checking rather than just hoping for the best.

    Here is the safe order to finish this:

    1. Back up the whole database before you run anything else on this table, just as already suggested above. A backup in the hosting control panel or an export from phpMyAdmin will do.
    2. Remove the line define(‘WP_ALLOW_REPAIR’, true); from wp-config.php. While that line is in place, anyone on the internet can trigger a repair on your database, so it should only be there during the repair itself.
    3. In phpMyAdmin, open the SQL tab and run CHECK TABLE wp_options; to see the current state of the table. If it still reports a problem, run REPAIR TABLE wp_options; and then run CHECK TABLE wp_options; once more to confirm it now reports OK.
    4. If the repair keeps failing or the row count keeps changing, stop running repairs and ask HostGator support to repair the table from the server side, and to check the MySQL error log and the free disk space on the account. A table that keeps crashing usually means the disk filled up, the server ran out of memory, or MySQL was stopped in the middle of a write, and no amount of clicking repair in the browser will fix the cause.
    5. Once the table reports OK, check that nothing important was lost. Look through Settings in the dashboard, confirm the site title, tagline and homepage settings are as they should be, and check that the plugins you expect are still active. If a setting has reverted to a default or a plugin has deactivated itself, restore just the wp_options table from a backup made before the crash.
    6. To stop this happening again, consider converting the table to InnoDB, which handles crashes far better than MyISAM. Patrick’s suggestion above covers the command for that, but only do the conversion after the backup and only when the table is already repaired and reporting OK.

    If the site still shows “Error establishing a database connection” after all this, double-check the database name, username, password and host in wp-config.php, and ask the host whether the database server itself is up. Good luck, and let us know what CHECK TABLE reports afterwards. 🔧

    Hi @silverinkandstardust, the steps above cover the repair well, so here is one extra check that can tell you whether anything important was lost. If you have a database backup from before the crash, export the wp_options table from the backup and from the live site and compare the two lists of option names. Any name that is in the backup but missing live is a lost setting, and you can then re-save just that setting in the dashboard instead of guessing. It is also worth checking the size of the autoloaded options, since a very large autoloaded value puts extra strain on this table and is loaded on every page. In phpMyAdmin, run SELECT option_name, LENGTH(option_value) AS size FROM wp_options WHERE autoload = ‘yes’ ORDER BY size DESC LIMIT 10; and look for anything unusually large, such as an old transient or a plugin storing a large amount of data there. If you find one, clearing or recreating that option, and checking whether the table crashes again after it reports OK, will tell you whether the problem is fixed or still coming back.

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.