Mysql – Restore MySQL Database with only .frm files

backupinnodbMySQLUbuntu

One of our servers (running Ubuntu 12.04) recently crashed during a power outage, and MySQL refused to start back up. After a lot of trial and error, I decided to completely reinstall it. Since I wasn't able to start any of the services, I couldn't do a dump, and there were no backups before that. I only have a copy of /var/lib/mysql.

Some databases have .MYD and .MYI files for all tables in the directory, so I was able to restore them fine by just copying the files. However, others only have the .frm files, and db.opt. There are no other files. I tried to stop the server, copy ibdata1 and ib_logfile1 and 2 from the backup directory and start it up again, but that always makes it crash again until I overwrite them with the fresh files.

Noteworthy:

  • Databases all show up with show databases
  • Tables all show up with show tables, but they're not listed in information_schema.TABLES.

There is some important data in the tables that aren't being recognized, and I'm really at a loss now. Is there any way to restore them?

Edit: The error log says this:

InnoDB: Database page corruption on disk or a failed InnoDB: file read of page 5. 
InnoDB: You may have to recover from a backup. 
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the 
InnoDB: error. 
InnoDB: If the corrupt page is an index page 
InnoDB: you can also try to fix the corruption 
InnoDB: by dumping, dropping, and reimporting 
InnoDB: the corrupt table. You can use CHECK 
InnoDB: TABLE to scan your table for corruption. 
InnoDB: See also http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html 
InnoDB: about forcing recovery.
InnoDB: Ending processing because of a corrupt database page. 150921 12:17:58  
InnoDB: Assertion failure in thread 3064645376 in file buf0buf.c line 3623
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery. 10:17:58 UTC - mysqld got signal 6 ; This could be because you hit a bug. It is also possible that this binary or one of the libraries it was linked against is corrupt, improperly built, or misconfigured. This error can also be caused by malfunctioning hardware. We will try our best to scrape up some info that will hopefully help diagnose the problem, but since we have already crashed,  something is definitely wrong and this may fail.
key_buffer_size=16777216 
read_buffer_size=131072 
max_used_connections=0 
max_threads=151 
thread_count=0
connection_count=0
It is possible that mysqld could use up to  key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 346076 K  bytes of memory Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0 Attempting backtrace. You can use the following information to find out where mysqld died. If you see no messages after this, something went terribly wrong... 
stack_bottom = 0 
thread_stack 0x30000
/usr/sbin/mysqld(my_print_stacktrace+0x33)[0xb72c90a3] 
/usr/sbin/mysqld(handle_fatal_signal+0x484)[0xb7174ce4] [0xb6e26404] 
/usr/sbin/mysqld(+0x58b708)[0xb73d4708] /usr/sbin/mysqld(+0x58c0e2)[0xb73d50e2] 
/usr/sbin/mysqld(+0x57baf7)[0xb73c4af7] 
/usr/sbin/mysqld(+0x54a05d)[0xb739305d]
/usr/sbin/mysqld(+0x54c619)[0xb7395619]
/usr/sbin/mysqld(+0x537ee7)[0xb7380ee7]
/usr/sbin/mysqld(+0x4fbc42)[0xb7344c42]
/usr/sbin/mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x4e)[0xb717750e]
/usr/sbin/mysqld(+0x1ff8e2)[0xb70488e2]
/usr/sbin/mysqld(_Z11plugin_initPiPPci+0xbe3)[0xb704c393]
/usr/sbin/mysqld(+0x16739a)[0xb6fb039a]
/usr/sbin/mysqld(_Z11mysqld_mainiPPc+0x6d1)[0xb6fb4381]
/usr/sbin/mysqld(main+0x27)[0xb6fa9517]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb6ae14d3] 
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains information that should help you find out what is causing the crash.

Unfortunately, restarting the OS did not solve the problem, and by that time MySQL was already not starting up anymore.

Best Answer

Try again but rename ib_logfile0 to ib_logfile0_old ib_logfile1 to ib_logfile1_old. These file automatically created from ibdata file when mysql server restart.

Try innodb_force_recovery option- mysql

[mysqld]
innodb_force_recovery = 1

If is not solving and i suggest to use recovery tool. Twindb and Percona

Related Question