Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL InnoDB tables are missing and not counted in database structure

Tags:

mysql

innodb

I have a serious problem in my MySQL tables , once there were InnoDB tables which were IN USE and now are somehow hidden

look at this [pic] *Link removed - the number of tables in heading is 79 and actual counted number is 74.

these tables are those that were IN USE

I don't have any recent backup of my database , so this would game of life and death for me

I checked my VPS, I found them at /etc/lib/mysql/db_name/.

EDIT :

I Searched around internet and I found out that every table should have 3 files related to it.

For example, the table table_users has:

 -- table_users.frm
 -- table_users.MYD
 -- table_users.MYI

and for those hidden table , there are only .frm files and the other two files of a table are missing.

I should change my question to: How to recover a innodb table from a .frm file?

like image 808
Mac Taylor Avatar asked Jun 03 '11 07:06

Mac Taylor


People also ask

Where can I find InnoDB in MySQL?

You can view a list of InnoDB INFORMATION_SCHEMA tables by issuing a SHOW TABLES statement on the INFORMATION_SCHEMA database: mysql> SHOW TABLES FROM INFORMATION_SCHEMA LIKE 'INNODB%'; For table definitions, see Section 26.4, “INFORMATION_SCHEMA InnoDB Tables”.

How do you check if MySQL table is InnoDB?

To determine whether your server supports InnoDB : Issue the SHOW ENGINES statement to view the available MySQL storage engines. mysql> SHOW ENGINES; Alternatively, query the INFORMATION_SCHEMA.


2 Answers

InnoDB does not have those three files

InnoDB data is stored in "ibdata1" for all databases and tables. the table definition is stored in "tablename.frm"

I would say that your InnoDB file has become corrupted, you may want to have a look at these tools: https://launchpad.net/percona-innodb-recovery-tool

like image 96
Geoffrey Avatar answered Sep 28 '22 07:09

Geoffrey


UPDATED

First of all, about the files:

  • .frm - table structure;
  • .myd - table data;
  • .myi - indexes.

To recover tables, you can try (make backup first):

1) run check table tablename - for all db tables;
2) run repair table tablename - for necessary tables.


UPDATED ONCE AGAIN

Another idea... Try this:

  1. Create a new database to restore and create the tables with same name as .frm files (with the one field - only to create new .frm files);
  2. Stop mysql service and replace the created .frm files with yours;
  3. Start mysql service and check.

I expect correct tables (without data, of course). And sorry, for now I have no PC to check, before suggesting...

like image 32
kpower Avatar answered Sep 28 '22 08:09

kpower