20111004 repairing wordpress database connection - plembo/onemoretech GitHub Wiki

title: Repairing Wordpress database connection link: https://onemoretech.wordpress.com/2011/10/04/repairing-wordpress-database-connection/ author: lembobro description: post_id: 1206 created: 2011/10/04 13:27:32 created_gmt: 2011/10/04 17:27:32 comment_status: closed post_name: repairing-wordpress-database-connection status: publish post_type: post

Repairing Wordpress database connection

Just now tried to access this site and got the dreaded "Error establishing a database connection" splash screen. Went up to Wordpress Support and found this post. Followed the advice given my the moderator and used phpMyAdmin to "Repair" the wp_options table -- which worked. But why? Basically what it looks like happened is that somehow, someway (outside hack? foobarred db edit by Wordpress itself? Issue with my my ISP's filesystem?). The "usual suspect" for this kind of thing is the value for 'siteurl' in wp_options. As it turned out only a few minutes later the entire database seems to have got iself in trouble and I was forced to run a repair on the whole thing, again inside phpMyAdmin. To do this without phpMyAdmin you first should confirm the db status by running the following after logging into the database with the mysql client: `

check table wp_options;

Next you need to verify what MySQL database engine type you're running, for example MyISAM or innoDB. Do that by going to a mysql prompt and running the following query:

select TABLE_NAME, ENGINE from
information_schema.tables
where TABLE_SCHEMA = 'mydbname';

This should list out all your tables with the database engine type for each, thus:

+-----------------------+--------+
| table_name            | engine |
+-----------------------+--------+
| wp_commentmeta        | MyISAM |
| wp_comments           | MyISAM |
| wp_links              | MyISAM |
| wp_options            | MyISAM |
| wp_postmeta           | MyISAM |
| wp_posts              | MyISAM |
| wp_term_relationships | MyISAM |
| wp_term_taxonomy      | MyISAM |
| wp_terms              | MyISAM |
| wp_usermeta           | MyISAM |
| wp_users              | MyISAM |
+-----------------------+--------+

If your engine type is MyISAM, you can use the following query to try repairing it:

repair table wp_options;

` Check these MySQL doc pages for more.

Copyright 2004-2019 Phil Lembo