{"id":3583,"date":"2012-07-30T12:57:36","date_gmt":"2012-07-30T04:57:36","guid":{"rendered":"http:\/\/www.janleow.com\/life\/?p=3583"},"modified":"2012-07-30T14:45:57","modified_gmt":"2012-07-30T06:45:57","slug":"how-to-recover-from-a-faulty-corrupted-wordpress-sql-database-caused-by-bad-plugins","status":"publish","type":"post","link":"https:\/\/www.janleow.com\/life\/how-to-recover-from-a-faulty-corrupted-wordpress-sql-database-caused-by-bad-plugins.html","title":{"rendered":"How to Recover from a Faulty Corrupted WordPress SQL Database caused by Bad Plugins"},"content":{"rendered":"<p>I guess eventually it would happen, the WordPress SQL database would eventually get corrupted from bad plugins. WordPress plugins are useful, but they also create configuration inserted into the WP_options MySQL table that are difficult to sort out. If the plugins worked well, no need to do anything. But if it misbehaves, just deleting the plugin may not necessary solve your WordPress website issues.<\/p>\n<p>My personal WordPress blog has been around for many years now, and there are hundreds of posts. In between I have tried many plugins to add functionality and more importantly to harden it against would be hackers and make it difficult for comment spammers. The latter two options tend to cause problem for WordPress installation somehow. Most especially the captcha plugins tend to cause my WordPress site to behave weirdly. My recent captcha was causing the entire site to lag and hog CPU resources!<!--more--><\/p>\n<p>My previous fixed up on the MySQL database was to go directly into WP_options table and look for the offending parameters to allow my WordPress to run smoothly after removing the plugin. However this was time consuming and takes guesswork to figure out which entries were to be deleted. It was risky too as I could accidentally delete legitimate parameters needed by WordPress and other plugins to work.<\/p>\n<p>This time round I figured out another way to clear all the gunk and leftover configurations from various plugins that was used and removed and of course remove parameters from runaway plugin scripts that were still causing the WordPress to lag and hog hosting resources despite deleting it from the installation.<\/p>\n<p>For some reason or another, I tried removing all plugins, but the WordPress was still lagging like a snails&#8217; race. Downloading the SQL database files and restore it to a brand new installation with all plugins running didn&#8217;t work either. Because I just moved the WP_options corrupted table from one WordPress installation to another. I tried using the export post feature, but the lag just done it in. It took ages to log in, and when I finally do get in, could not really navigate around due to heavy lag, and when I did get into the tool section the export post just died. Not able to extract my posts meant all my years of blog post would be gone. The serious lag was also causing 404 file not found errors and I was getting warning emails from Google Webmaster too about pages not found!<\/p>\n<p>So I came up with this plan to extract my posts and pages, and it worked flawlessly. Here are my steps and hopefully if you similar issues you could use it too.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.janleow.com\/imgs\/wp\/cpanel-backup-database.jpg\" alt=\"cPanel Back up manager and MySQL phpMyAdmin database\" \/><\/p>\n<h3>How to extract WordPress Posts and Pages from a faulty MySQL database and restore to a new WordPress instalation<\/h3>\n<ul>\n<li>Backup MySQL database file and download a copy to the hard disk. Also backup the WordPress theme and plugins and any other modifications for later restore. (in cPanel, goto the Backup icon to do it, otherwise do it the hard way via phpMyAdmin)\n<li>Create a new temporary WordPress installation in a different location or folder, make sure you use the same WordPress table prefix during creation, for the sake of this explanation, the table prefix is wp_\n<li>Restore the MySQL database into this new WordPress by importing it via phpMyAdmin\n<li>In phpMyAdmin, edit table wp_option, the first entry is the blog URL, change it to match the new location or you won&#8217;t be able to see your old posts\n<li>Login to your temporary WordPress installation, navigate to TOOLS, then EXPORT all your posts and pages to a XML file and download it to your PC\n<li>Delete your old faulty WordPress including the old MySQL database and install a new version over it\n<li>Check your hosting PHP configuration for the upload_max_filesize. If the settings is 2MB you will not be able to upload the XML files if larger than this. So you will need to create a PHP.ini file to override this limitation\n<li>Create a PHP.ini file and add these two lines<br \/>\n<blockquote><p>\nfile_uploads = On  ; Whether to allow HTTP file uploads<br \/>\nupload_max_filesize = 6M   ; Maximum allowed size for uploaded files\n<\/p><\/blockquote>\n<p>In my case, my XML file was 4MB, so I set it to 6MB.<br \/>\nPlace the PHP.ini file into every folder of WordPress that runs PHP script<\/p>\n<li>Login to your new WordPress installation and navigate to TOOLS and IMPORT\n<li>You will need to install the WordPress import plugin to import the XML file\n<li>After successfully import, check your old post and see if shows up, if yes, success!\n<li>Restore your old themes (and plugins, but carefully) and other modifications and you are done!\n<\/ul>\n<p>The above method strips off a lot of gunk from the MySQL database. Upon checking my database, I found it was now a lot slimmer than before. From a previous size of about 18MB to a neat little 4MB database size. The WordPress site also runs smoother and that should satisfy the search bots and prevent the 404 file not found errors.<\/p>\n<p>Only one problem, for some strange reason, one of my posts still could not be updated and still get 403 file permission error. All other old post I have no problem updated the content. Really weird. As long as I don&#8217;t touch it I suppose I can live with that. With this WordPress post extraction and restoration method, I now I have my website back on track!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I guess eventually it would happen, the WordPress SQL database would eventually get corrupted from bad plugins. WordPress plugins are useful, but they also create configuration inserted into the WP_options MySQL table that are difficult to sort out. If the plugins worked well, no need to do anything. But if it misbehaves, just deleting the &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.janleow.com\/life\/how-to-recover-from-a-faulty-corrupted-wordpress-sql-database-caused-by-bad-plugins.html\"> <span class=\"screen-reader-text\">How to Recover from a Faulty Corrupted WordPress SQL Database caused by Bad Plugins<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[12],"tags":[162,165],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1bS5F-VN","jetpack-related-posts":[{"id":859,"url":"https:\/\/www.janleow.com\/life\/fixed-wordpress-websites-auto-install-using-simple-script.html","url_meta":{"origin":3583,"position":0},"title":"Fixed my WordPress websites auto install using Simple Script","author":"Jan","date":"3 November 2008","format":false,"excerpt":"During my last upgrade, I crashed my Wordpress websites and after I made the web site to work, it broke the Fantastico DeLuxe automatic upgrade feature. Manual upgrading was a little tedious and I had to go through several steps to make any update to the Wordpress installation. I did\u2026","rel":"","context":"In &quot;Website&quot;","block_context":{"text":"Website","link":"https:\/\/www.janleow.com\/life\/category\/website"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2887,"url":"https:\/\/www.janleow.com\/life\/b2evolution-for-blogging.html","url_meta":{"origin":3583,"position":1},"title":"B2Evolution for Blogging","author":"Jan","date":"25 January 2011","format":false,"excerpt":"I was toying around with B2 Evolution which is used for blogging. Thought I try an alternate from the popular Wordpress installation and see how it goes. On the first look, the B2 Evolution looks great and it has multiple section for your blogging needs. You can create blog A\u2026","rel":"","context":"In &quot;Website&quot;","block_context":{"text":"Website","link":"https:\/\/www.janleow.com\/life\/category\/website"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":734,"url":"https:\/\/www.janleow.com\/life\/make-your-own-wordpress-website.html","url_meta":{"origin":3583,"position":2},"title":"Make your websites using WordPress","author":"Jan","date":"13 August 2008","format":false,"excerpt":"Wordpress by far is the most popular software used for blogging. Almost every self-hosted website that was build for blogging uses Wordpress. It sheer versatility, ease of use, numerous themes and plugins available make it the choice script to install. In addition, if you decided to turn your Wordpress blog\u2026","rel":"","context":"In &quot;Website&quot;","block_context":{"text":"Website","link":"https:\/\/www.janleow.com\/life\/category\/website"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1191,"url":"https:\/\/www.janleow.com\/life\/hardening-wordpress-website-is-a-must.html","url_meta":{"origin":3583,"position":3},"title":"Hardening WordPress website is a must!","author":"Jan","date":"1 December 2009","format":false,"excerpt":"Earlier this year, one of my friends Wordpress website and Drupal website was hacked. Both of them were running a travel website and their site was stuff full of web spam with links to dubious website selling dubious products. Appears this was no isolated incident and I have come across\u2026","rel":"","context":"In &quot;Website&quot;","block_context":{"text":"Website","link":"https:\/\/www.janleow.com\/life\/category\/website"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1135,"url":"https:\/\/www.janleow.com\/life\/some-problem-with-simple-script.html","url_meta":{"origin":3583,"position":4},"title":"Some problem with Simple Script","author":"Jan","date":"13 August 2009","format":false,"excerpt":"Recently I wanted to update my database driven software like this Wordpress which was managed by Simple Script. Sure, using Simple Script to manage my software installations in Bluehost was really convenient, but I didn't expect to see hiccups in their updating of software. Try as I might, the installations\u2026","rel":"","context":"In &quot;Website&quot;","block_context":{"text":"Website","link":"https:\/\/www.janleow.com\/life\/category\/website"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":728,"url":"https:\/\/www.janleow.com\/life\/make-drupal-website-cms-content-management-software.html","url_meta":{"origin":3583,"position":5},"title":"Making a Drupal Web Site","author":"Jan","date":"22 July 2008","format":false,"excerpt":"Drupal is like a jack of all trades. You could use it for setting a proper website with tier like structure for easy navigation, you could use it to set up a forum, or you just use it to set up a blogging site. It is so versatile that according\u2026","rel":"","context":"In &quot;Website&quot;","block_context":{"text":"Website","link":"https:\/\/www.janleow.com\/life\/category\/website"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/posts\/3583"}],"collection":[{"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/comments?post=3583"}],"version-history":[{"count":7,"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/posts\/3583\/revisions"}],"predecessor-version":[{"id":3590,"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/posts\/3583\/revisions\/3590"}],"wp:attachment":[{"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/media?parent=3583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/categories?post=3583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.janleow.com\/life\/wp-json\/wp\/v2\/tags?post=3583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}