{"id":382,"date":"2009-04-11T13:04:24","date_gmt":"2009-04-11T16:04:24","guid":{"rendered":"https:\/\/devkico.itexto.com.br\/?p=382"},"modified":"2009-04-11T13:25:13","modified_gmt":"2009-04-11T16:25:13","slug":"how-to-restore-myisaminnodb-tables-in-a-mysql-50-server","status":"publish","type":"post","link":"https:\/\/devkico.itexto.com.br\/?p=382","title":{"rendered":"How to restore corrupted MyISAM\/InnoDB tables on MySQL 5.0"},"content":{"rendered":"<p><a href=\"https:\/\/devkico.itexto.com.br\/wp-content\/uploads\/2009\/04\/munch_scream.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-379\" style=\"margin: 10px;\" title=\"munch_scream\" src=\"https:\/\/devkico.itexto.com.br\/wp-content\/uploads\/2009\/04\/munch_scream-200x300.jpg\" alt=\"\" width=\"200\" height=\"300\" srcset=\"https:\/\/devkico.itexto.com.br\/wp-content\/uploads\/2009\/04\/munch_scream-200x300.jpg 200w, https:\/\/devkico.itexto.com.br\/wp-content\/uploads\/2009\/04\/munch_scream.jpg 300w\" sizes=\"(max-width: 200px) 100vw, 200px\" \/><\/a> I know that it&#8217;s not our job to manage database servers. But if you don&#8217;t have a competent crew for that, you have to face the problem yourself.<\/p>\n<p>Well, here is what happened to me this week. Waiting for the end of the day, in which the number of connections to our MySQL server is quite low, I started the creation of a new index on a huge MyISAM table (14 Gb), which is used to store the logs of our systems. While the index was being created, our &#8220;network administrator&#8221; received some complaints from our users that the systems were to slow. What was his solution? Shut down the server! In this process, logically our huge table was lost and, even worse, the MySQL server couldn&#8217;t be restarted at all!<\/p>\n<p>Many of our InnoDB and MyISAM tables were corrupted because of this &#8220;little&#8221; mistake. So, after some hours of research I discovered a simple procedure that can restore all your data (or at least most of it). This procedure is composed of three steps:<\/p>\n<p>1. Execute the myisamchk software inside your MySQL data directory. If you don&#8217;t know where this directory is, check the parameter datadir on your MySQL configuration file (my.ini on Windows, my.cfg on Linux\/Unix).<\/p>\n<p>You must use two parameters: &#8211;force and &#8211;verbose (which is optional) like bellow:<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">myisamchk --force --verbose *\/*.MYI<\/pre>\n<p>The &#8211;force parameter will instruct myisamchk to repair automatically every problem it may encounter on your MyISAM tables, while the &#8211;verbose (which is optional) will only show the status of execution of the myisamchk program on your screen.<\/p>\n<p>2. Start the MySQL server with the parameter <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/forcing-recovery.html\" target=\"_blank\">&#8211;innodb_force_recovery<\/a><br \/>\nTry to start your MySQL server with this parameter. The value must be a number between 1 and 6. As higher it&#8217;s value, worst are the problems on your MySQL tablespace.<\/p>\n<p>Example:<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">mysqld --innodb_force_recovery=4<\/pre>\n<p>If you only got to start your MySQL server with a value bigger than four, your databases will be in read only mode. If not, your users may use the server normally.<\/p>\n<p>If you wish, you may also add the command innodb_force_recovery to your MySQL configuration file as in the example bellow:<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\r\n&#x5B;mysqld]\r\ninnodb_force_recovery=4\r\n\r\n<\/pre>\n<p>3. After your MySQL server starts, backup your data and then restore them on a new MySQL installation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I know that it&#8217;s not our job to manage database servers. But if you don&#8217;t have a competent crew for that, you have to face the problem yourself. Well, here is what happened to me this week. Waiting for the end of the day, in which the number of connections to our MySQL server is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-382","post","type-post","status-publish","format-standard","hentry","category-mysql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to restore corrupted MyISAM\/InnoDB tables on MySQL 5.0 - \/dev\/Kico<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/devkico.itexto.com.br\/?p=382\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to restore corrupted MyISAM\/InnoDB tables on MySQL 5.0 - \/dev\/Kico\" \/>\n<meta property=\"og:description\" content=\"I know that it&#8217;s not our job to manage database servers. But if you don&#8217;t have a competent crew for that, you have to face the problem yourself. Well, here is what happened to me this week. Waiting for the end of the day, in which the number of connections to our MySQL server is [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/devkico.itexto.com.br\/?p=382\" \/>\n<meta property=\"og:site_name\" content=\"\/dev\/Kico\" \/>\n<meta property=\"article:published_time\" content=\"2009-04-11T16:04:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2009-04-11T16:25:13+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.itexto.net\/devkico\/wp-content\/uploads\/2009\/04\/munch_scream-200x300.jpg\" \/>\n<meta name=\"author\" content=\"Kico (Henrique Lobo Weissmann)\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@loboweissmann\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kico (Henrique Lobo Weissmann)\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. tempo de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/devkico.itexto.com.br\/?p=382\",\"url\":\"https:\/\/devkico.itexto.com.br\/?p=382\",\"name\":\"How to restore corrupted MyISAM\/InnoDB tables on MySQL 5.0 - \/dev\/Kico\",\"isPartOf\":{\"@id\":\"https:\/\/devkico.itexto.com.br\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/devkico.itexto.com.br\/?p=382#primaryimage\"},\"image\":{\"@id\":\"https:\/\/devkico.itexto.com.br\/?p=382#primaryimage\"},\"thumbnailUrl\":\"https:\/\/devkico.itexto.com.br\/wp-content\/uploads\/2009\/04\/munch_scream-200x300.jpg\",\"datePublished\":\"2009-04-11T16:04:24+00:00\",\"dateModified\":\"2009-04-11T16:25:13+00:00\",\"author\":{\"@id\":\"https:\/\/devkico.itexto.com.br\/#\/schema\/person\/502ab8892631bb005d6da2269fe5a3a7\"},\"breadcrumb\":{\"@id\":\"https:\/\/devkico.itexto.com.br\/?p=382#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/devkico.itexto.com.br\/?p=382\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/devkico.itexto.com.br\/?p=382#primaryimage\",\"url\":\"https:\/\/devkico.itexto.com.br\/wp-content\/uploads\/2009\/04\/munch_scream-200x300.jpg\",\"contentUrl\":\"https:\/\/devkico.itexto.com.br\/wp-content\/uploads\/2009\/04\/munch_scream-200x300.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/devkico.itexto.com.br\/?p=382#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/devkico.itexto.com.br\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to restore corrupted MyISAM\/InnoDB tables on MySQL 5.0\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/devkico.itexto.com.br\/#website\",\"url\":\"https:\/\/devkico.itexto.com.br\/\",\"name\":\"\/dev\/Kico\",\"description\":\"Desenvolvendo software\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/devkico.itexto.com.br\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/devkico.itexto.com.br\/#\/schema\/person\/502ab8892631bb005d6da2269fe5a3a7\",\"name\":\"Kico (Henrique Lobo Weissmann)\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/devkico.itexto.com.br\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/dd6973d86a689bc63122b2e603f25be3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/dd6973d86a689bc63122b2e603f25be3?s=96&d=mm&r=g\",\"caption\":\"Kico (Henrique Lobo Weissmann)\"},\"sameAs\":[\"https:\/\/x.com\/loboweissmann\"],\"url\":\"https:\/\/devkico.itexto.com.br\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to restore corrupted MyISAM\/InnoDB tables on MySQL 5.0 - \/dev\/Kico","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/devkico.itexto.com.br\/?p=382","og_locale":"pt_BR","og_type":"article","og_title":"How to restore corrupted MyISAM\/InnoDB tables on MySQL 5.0 - \/dev\/Kico","og_description":"I know that it&#8217;s not our job to manage database servers. But if you don&#8217;t have a competent crew for that, you have to face the problem yourself. Well, here is what happened to me this week. Waiting for the end of the day, in which the number of connections to our MySQL server is [&hellip;]","og_url":"https:\/\/devkico.itexto.com.br\/?p=382","og_site_name":"\/dev\/Kico","article_published_time":"2009-04-11T16:04:24+00:00","article_modified_time":"2009-04-11T16:25:13+00:00","og_image":[{"url":"http:\/\/www.itexto.net\/devkico\/wp-content\/uploads\/2009\/04\/munch_scream-200x300.jpg"}],"author":"Kico (Henrique Lobo Weissmann)","twitter_card":"summary_large_image","twitter_creator":"@loboweissmann","twitter_misc":{"Escrito por":"Kico (Henrique Lobo Weissmann)","Est. tempo de leitura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/devkico.itexto.com.br\/?p=382","url":"https:\/\/devkico.itexto.com.br\/?p=382","name":"How to restore corrupted MyISAM\/InnoDB tables on MySQL 5.0 - \/dev\/Kico","isPartOf":{"@id":"https:\/\/devkico.itexto.com.br\/#website"},"primaryImageOfPage":{"@id":"https:\/\/devkico.itexto.com.br\/?p=382#primaryimage"},"image":{"@id":"https:\/\/devkico.itexto.com.br\/?p=382#primaryimage"},"thumbnailUrl":"https:\/\/devkico.itexto.com.br\/wp-content\/uploads\/2009\/04\/munch_scream-200x300.jpg","datePublished":"2009-04-11T16:04:24+00:00","dateModified":"2009-04-11T16:25:13+00:00","author":{"@id":"https:\/\/devkico.itexto.com.br\/#\/schema\/person\/502ab8892631bb005d6da2269fe5a3a7"},"breadcrumb":{"@id":"https:\/\/devkico.itexto.com.br\/?p=382#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/devkico.itexto.com.br\/?p=382"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/devkico.itexto.com.br\/?p=382#primaryimage","url":"https:\/\/devkico.itexto.com.br\/wp-content\/uploads\/2009\/04\/munch_scream-200x300.jpg","contentUrl":"https:\/\/devkico.itexto.com.br\/wp-content\/uploads\/2009\/04\/munch_scream-200x300.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/devkico.itexto.com.br\/?p=382#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/devkico.itexto.com.br\/"},{"@type":"ListItem","position":2,"name":"How to restore corrupted MyISAM\/InnoDB tables on MySQL 5.0"}]},{"@type":"WebSite","@id":"https:\/\/devkico.itexto.com.br\/#website","url":"https:\/\/devkico.itexto.com.br\/","name":"\/dev\/Kico","description":"Desenvolvendo software","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/devkico.itexto.com.br\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"pt-BR"},{"@type":"Person","@id":"https:\/\/devkico.itexto.com.br\/#\/schema\/person\/502ab8892631bb005d6da2269fe5a3a7","name":"Kico (Henrique Lobo Weissmann)","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/devkico.itexto.com.br\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/dd6973d86a689bc63122b2e603f25be3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dd6973d86a689bc63122b2e603f25be3?s=96&d=mm&r=g","caption":"Kico (Henrique Lobo Weissmann)"},"sameAs":["https:\/\/x.com\/loboweissmann"],"url":"https:\/\/devkico.itexto.com.br\/?author=1"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/devkico.itexto.com.br\/index.php?rest_route=\/wp\/v2\/posts\/382"}],"collection":[{"href":"https:\/\/devkico.itexto.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devkico.itexto.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devkico.itexto.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/devkico.itexto.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=382"}],"version-history":[{"count":3,"href":"https:\/\/devkico.itexto.com.br\/index.php?rest_route=\/wp\/v2\/posts\/382\/revisions"}],"predecessor-version":[{"id":385,"href":"https:\/\/devkico.itexto.com.br\/index.php?rest_route=\/wp\/v2\/posts\/382\/revisions\/385"}],"wp:attachment":[{"href":"https:\/\/devkico.itexto.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devkico.itexto.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devkico.itexto.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}