MySQL “lost” all data (InnoBD)

2

1

Today I was making some work with site and I get error what MySQL can't rename file (to make changes in BD). Next I tried to restart MySQL, and it failed to stop MySQL. Then I did go to /var/lib/mysql and all I see is: ib_logfile0+1, ibdata1, and site folder, with tables that I was changing (not tables themselves, just #sql-b61_25a8e.MYI).

Can I recover my MySQL data? I don't need all tables, because I have old backup of them. I just need that one table with all users (I was changing table with users). And yes, I did shutdown MySQL for some stupid reason.

fhntv24

Posted 2014-02-16T11:50:54.487

Reputation: 33

perhaps better asked at stackoverflow.com – Tomas – 2014-02-16T11:53:00.420

http://stackoverflow.com/questions/21810413/mysql-lost-all-datainnobd lol,they are sending me to here,and you sending me to there... – fhntv24 – 2014-02-16T11:55:40.447

1@Tomas I'm pretty much sure this is the right place. Configuring and recovering databases are on-topic here. Specifics of SQL queries obviously belong to Stack Overflow. – Olli – 2014-02-16T12:19:03.810

Have you tried force recovery? This may allow MySQL to start up so that you can dump/backup the users table, but won't allow changes. Also, the MySQL error log -- starting with the crash -- would be helpful.

– SgtOJ – 2014-02-16T13:56:28.743

Answers

1

First off, where are your backups? If you don't have any, this should be your first task after recovering your data.

Anyhow, as long as you have a copy of your .frm files, you can recover the data. Those files are usually located in the same directory as you DB data, e. g. /var/lib/mysql, but maybe your setup differs. If you have no copy of your .frm files, you need to re-create them. frm-files statically store your table layout, so shouldn't be too hard to re-create, provided you have kept your design papers or you use a provided application such as Wordpress. Then just create new instance of the application and copy the frm-files to your recovery machine.

For recovery follow these simple steps:

  1. Set up a new MySQL server on another machine, but do not start mysqld yet.
  2. Copy your ibdata1, ib_logfile0 and ib_logfile1 to the new machine's /var/lib/mysql folder.
  3. Make sure that these files belong to the MySQL user, e. g. chown mysql ibdata1 ...
  4. Find the size of the logfiles in bytes, e. g. ls -l.
  5. Become the MySQL user, e. g. su mysql.
  6. Start the mysqld with recovery options, i. e. /usr/sbin/mysqld –innodb_log_file_size=<size_inbytes> –innodb_force_recovery=6

Now you should see some messages from MySQL, such as which options you set. After a short while mysqld should be up and running. Once this has happened you can pull a correct copy of your database with mysqldump and import the copy into your production machine.

bjanssen

Posted 2014-02-16T11:50:54.487

Reputation: 2 289

yea that is right answer,but i get it also at ServerFault.Becaos that is right answer,then lets mark you as right answer ;) – fhntv24 – 2014-02-17T05:49:07.373