MySQL doesn't see tables after recovering DB from HDD crash

SilverNodashi

Expert Member
Joined
Oct 12, 2007
Messages
3,340
Reaction score
49
Location
Johannesburg, South Africa
Hi all,

I had to manually restore a few databases from a CentOS server that crashed, but MySQL doesn't see one of the DB's tables.

The server uses hardware RAID 10 and the RAID controller crashed, taking down 3 drives in the RAID 10 array. We have managed to rebuild the RAID10 array in another server and recover most of the data.
And the backups of this particular DB is rather old so I need to try and recover it from the old HDD

The DB files were basically copied from the old HDD to the new one as follows:

PHP:
 rsync -avp --progress /oldhdd/var/lib/mysql/ap09sw56_DG6trJAa/* /var/lib/mysql/african1_DG6trJAa/
  516  /etc/init.d/mysql reload


The tables are supposedly there:

PHP:
mysql> show tables;
+-----------------------------------------+
| Tables_in_african1_DG6trJAa             |
+-----------------------------------------+
| ggtr_access                             |
| ggtr_accessory                          |
| ggtr_address                            |
| ggtr_address_format                     |
| ggtr_alias                              |
| ggtr_attachment                         |
| ggtr_attachment_lang                    |
| ggtr_attribute                          |
| ggtr_attribute_group                    |
| ggtr_attribute_group_lang               |
| ggtr_attribute_impact                   |
| ggtr_attribute_lang                     |
| ggtr_blocklink                          |
| ggtr_blocklink_lang                     |
| ggtr_carrier                            |
| ggtr_carrier_group                      |
| ggtr_carrier_lang                       |
| ggtr_carrier_zone                       |
| ggtr_cart                               |
| ggtr_cart_discount                      |
| ggtr_cart_product                       |
| ggtr_category                           |
| ggtr_category_group                     |
| ggtr_category_lang                      |
| ggtr_category_product                   |
| ggtr_cms                                |
| ggtr_cms_block                          |
| ggtr_cms_block_lang                     |
| ggtr_cms_block_page


Yet, MySQL doesn't seem to find them:

PHP:
mysql> repair table ggtr_cms;
+----------------------------+--------+----------+--------------------------------------------------+
| Table                      | Op     | Msg_type | Msg_text                                         |
+----------------------------+--------+----------+--------------------------------------------------+
| african1_DG6trJAa.ggtr_cms | repair | Error    | Table 'african1_DG6trJAa.ggtr_cms' doesn't exist |
| african1_DG6trJAa.ggtr_cms | repair | status   | Operation failed                                 |
+----------------------------+--------+----------+--------------------------------------------------+
2 rows in set (0.00 sec)

mysql> check table ggtr_cms;
+----------------------------+-------+----------+--------------------------------------------------+
| Table                      | Op    | Msg_type | Msg_text                                         |
+----------------------------+-------+----------+--------------------------------------------------+
| african1_DG6trJAa.ggtr_cms | check | Error    | Table 'african1_DG6trJAa.ggtr_cms' doesn't exist |
| african1_DG6trJAa.ggtr_cms | check | status   | Operation failed                                 |
+----------------------------+-------+----------+--------------------------------------------------+
2 rows in set (0.00 sec)



But, the files do exist on the server:



PHP:
root@venus:[~]$ ll /var/lib/mysql/african1_DG6trJAa/ggtr_cms*
-rw-rw---- 1 mysql mysql 8688 Jun  6 08:26 /var/lib/mysql/african1_DG6trJAa/ggtr_cms.frm
-rw-rw---- 1 mysql mysql 8752 Jun  6 08:26 /var/lib/mysql/african1_DG6trJAa/ggtr_cms_block.frm
-rw-rw---- 1 mysql mysql 8642 Jun  6 08:26 /var/lib/mysql/african1_DG6trJAa/ggtr_cms_block_lang.frm
-rw-rw---- 1 mysql mysql 8710 Jun  6 08:26 /var/lib/mysql/african1_DG6trJAa/ggtr_cms_block_page.frm
-rw-rw---- 1 mysql mysql 8814 Jun  6 08:26 /var/lib/mysql/african1_DG6trJAa/ggtr_cms_category.frm
-rw-rw---- 1 mysql mysql 8882 Jun  6 08:26 /var/lib/mysql/african1_DG6trJAa/ggtr_cms_category_lang.frm
-rw-rw---- 1 mysql mysql 8826 Jun  6 08:26 /var/lib/mysql/african1_DG6trJAa/ggtr_cms_lang.frm





I performed the exact same procedure on 3 other MySQL DB's and it worked fine.


And the google search results I got for this problem didn't actually give me any solutions. In fact in most posts I read the answer was "check your firewall" - which doesn't actually help at all. I'm on the MySQL server using the command line MySQL client.




Has anyone run into a similar problem, and managed to recover the data successfully?
 
You should have 3 files for every table:
Code:
-rw-rw---- 1 mysql mysql  8650 Sep  9 12:07 bench_9.frm
-rw-rw---- 1 mysql mysql     0 Sep  9 12:07 bench_9.MYD
-rw-rw---- 1 mysql mysql  1024 Sep  9 12:07 bench_9.MYI

I don't think the .frm file on its own will be enough to get everything mysql need.
 
Does the database use MyISAM? If so then

touch /var/lib/mysql/african1_DG6trJAa/ggtr_cms.MYI
touch /var/lib/mysql/african1_DG6trJAa/ggtr_cms.MYD

REPAIR TABLE ggtr_cms USE_FRM

Remember to chown the 2 files made above.
 
Top
Sign up to the MyBroadband newsletter
X