<input type="hidden" id="_wpnonce" name="_wpnonce" value="554d87a88e" /><input type="hidden" name="_wp_http_referer" value="/blog/wp-json/wp/v2/posts/6902" /><input type="hidden" id="_wpnonce" name="_wpnonce" value="554d87a88e" /><input type="hidden" name="_wp_http_referer" value="/blog/wp-json/wp/v2/posts/6902" />{"id":6902,"date":"2017-01-13T17:35:57","date_gmt":"2017-01-13T06:35:57","guid":{"rendered":"https:\/\/www.businesslegions.com\/blog\/?p=6902"},"modified":"2017-01-13T17:35:57","modified_gmt":"2017-01-13T06:35:57","slug":"fix-corrupted-table-mysql-database","status":"publish","type":"post","link":"https:\/\/www.businesslegions.com\/blog\/2017\/01\/13\/fix-corrupted-table-mysql-database\/","title":{"rendered":"HOW TO FIX A CORRUPTED TABLE IN A MYSQL DATABASE"},"content":{"rendered":"<!--CusAds0--><p>One of the websites I manage <a href=\"http:\/\/www.digitalsignageblog.com\" target=\"_blank\">Digital Signage Blog<\/a> was not displaying correctly (posts were not displaying, menu was missing links to the categories and only displaying pages)\u00a0and after some investigation, I discovered one of the database tables (the categories table &#8211; wp_term_taxonomy) was corrupted. I attempted to repair the database by using these instructions <a href=\"https:\/\/www.businesslegions.com\/blog\/2014\/09\/26\/check-repair-mysql-tables-using-mysqlcheck\/\" target=\"_blank\">How to check and repair MySQL tables using MySQLcheck<\/a>\u00a0and <a href=\"https:\/\/www.businesslegions.com\/blog\/2015\/06\/30\/wordpress-database-repair\/\" target=\"_blank\">How to repair WordPress databases<\/a> but both instructions didn&#8217;t work.<\/p>\n<p>When I ran the repairs using the above methods there were no errors being reported that the database was corrupted. The only way I figured out that one of the tables was actually corrupted was to login to phpMyAdmin and saw the status of the table being in use.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-6950 size-large\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/How-to-Fix-MySQL-Database-Table-Error-in-use-883x666.png?strip=all\" width=\"883\" height=\"666\" srcset=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/How-to-Fix-MySQL-Database-Table-Error-in-use-883x666.png?strip=all 883w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/How-to-Fix-MySQL-Database-Table-Error-in-use.png?strip=all&amp;zoom=0.2&amp;resize=883%2C666 176w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/How-to-Fix-MySQL-Database-Table-Error-in-use.png?strip=all&amp;zoom=0.4&amp;resize=883%2C666 353w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/How-to-Fix-MySQL-Database-Table-Error-in-use.png?strip=all&amp;zoom=0.6&amp;resize=883%2C666 529w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/How-to-Fix-MySQL-Database-Table-Error-in-use.png?strip=all&amp;zoom=0.8&amp;resize=883%2C666 706w\" sizes=\"(max-width: 883px) 100vw, 883px\" \/><\/p>\n<p>When I tried repairing that particular table using phpMyAdmin and it reported &#8216;Can&#8217;t create new tempfile:..&#8217; and the &#8216;Operation failed&#8217;<\/p><!--CusAds0-->\n<p><img decoding=\"async\" class=\"alignnone wp-image-6952 size-large\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/How-to-Fix-MySQL-Database-Table-Error-in-use-Cant-open-new-tempfile-error-1-883x666.png?strip=all\" width=\"883\" height=\"666\" srcset=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/How-to-Fix-MySQL-Database-Table-Error-in-use-Cant-open-new-tempfile-error-1-883x666.png?strip=all 883w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/How-to-Fix-MySQL-Database-Table-Error-in-use-Cant-open-new-tempfile-error-1.png?strip=all&amp;zoom=0.2&amp;resize=883%2C666 176w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/How-to-Fix-MySQL-Database-Table-Error-in-use-Cant-open-new-tempfile-error-1.png?strip=all&amp;zoom=0.4&amp;resize=883%2C666 353w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/How-to-Fix-MySQL-Database-Table-Error-in-use-Cant-open-new-tempfile-error-1.png?strip=all&amp;zoom=0.6&amp;resize=883%2C666 529w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/How-to-Fix-MySQL-Database-Table-Error-in-use-Cant-open-new-tempfile-error-1.png?strip=all&amp;zoom=0.8&amp;resize=883%2C666 706w\" sizes=\"(max-width: 883px) 100vw, 883px\" \/><\/p>\n<p>So to fix this I had to login to my VPS and use the SSH terminal to issue the following commands. Firstly go to the database files<\/p>\n<pre class=\"lang:default decode:true \">cd \/var\/lib\/mysql\/[name_of_your_database]<\/pre>\n<p>Then use this command to fix it:<\/p>\n<pre class=\"lang:default decode:true \">myisamchk -r -f wp-term_taxonomy.MYI<\/pre>\n<p>This was the result, it fixed 3 indexes.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-6953\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/myisamchk-repair.png?strip=all\" alt=\"myisamchk repair\" width=\"668\" height=\"421\" srcset=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/myisamchk-repair.png?strip=all 668w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/myisamchk-repair-300x189.png?strip=all 300w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/myisamchk-repair-178x112.png?strip=all 178w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/myisamchk-repair.png?strip=all&amp;w=400 400w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/myisamchk-repair.png?strip=all&amp;w=534 534w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2017\/01\/myisamchk-repair.png?strip=all&amp;w=450 450w\" sizes=\"(max-width: 668px) 100vw, 668px\" \/><\/p>\n<p>Here&#8217;s a video of how to do this:<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/t16PSWf849o\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<div class=\"lt-box\" style=\"border:1px solid #1d6a9e\"><div class=\"lt-box-title\" style=\"background-color:#2485C6;border-top:1px solid #a7cee8;text-shadow:1px 1px 0 #0b283b\">DO YOU LIKE WHAT YOU'VE READ?<\/div><div class=\"lt-box-content\">Join our subscription list and receive our content right in your mailbox. If you like to receive some Great deals our Freebies then subscribe now!\r\n\r\n<p><div class=\"tnp tnp-subscription \">\n<form method=\"post\" action=\"https:\/\/www.businesslegions.com\/blog\/wp-admin\/admin-ajax.php?action=tnp&amp;na=s\">\n<input type=\"hidden\" name=\"nlang\" value=\"\">\n<div class=\"tnp-field tnp-field-firstname\"><label for=\"tnp-1\">Name<\/label>\n<input class=\"tnp-name\" type=\"text\" name=\"nn\" id=\"tnp-1\" value=\"\" placeholder=\"\"><\/div>\n<div class=\"tnp-field tnp-field-email\"><label for=\"tnp-2\">Email<\/label>\n<input class=\"tnp-email\" type=\"email\" name=\"ne\" id=\"tnp-2\" value=\"\" placeholder=\"\" required><\/div>\n<div class=\"tnp-field tnp-field-button\" style=\"text-align: left\"><input class=\"tnp-submit\" type=\"submit\" value=\"Subscribe\" style=\"\">\n<\/div>\n<\/form>\n<\/div>\n<\/p>\r\n\r\n<\/div><\/div><!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>One of the websites I manage Digital Signage Blog was not displaying correctly (posts were not displaying, menu was missing links to the categories and only displaying pages)\u00a0and after some investigation, I discovered one of the database tables (the categories table &#8211; wp_term_taxonomy) was corrupted. I attempted to repair the database by using these instructions [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6962,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[830,3,1691,1043,3499],"tags":[3897,497,747,1901,1778,146,303],"class_list":["post-6902","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-technology","category-technology","category-tip-and-tricks","category-websites","category-wordpress-2","tag-corrupt","tag-database","tag-mysql","tag-repair","tag-table","tag-video","tag-vps"],"_links":{"self":[{"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/posts\/6902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/comments?post=6902"}],"version-history":[{"count":5,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/posts\/6902\/revisions"}],"predecessor-version":[{"id":6961,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/posts\/6902\/revisions\/6961"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/media\/6962"}],"wp:attachment":[{"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/media?parent=6902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/categories?post=6902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/tags?post=6902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}