Lalit Kaushik
Lalit Kaushik

Reputation: 1062

How can I recover currupt database in magento?

I setup fresh xampp(latest version) and copy mysql/data folder from old xampp(little bit lower version).

When I am access my magento project database through phpmyadmin, i am shocked. Here only 19 tables listed.

I checked in mysql/data directory, database folder and files with tables name(*.frm) are exist.

Please let me know how can i get back my complete database?

PS: I am using window 7.

Upvotes: 0

Views: 730

Answers (2)

espradley
espradley

Reputation: 2148

When copying Magento Database, be sure to use "Single Transactions". Otherwise, it will cause issues.

this is how I do it using command line:

  1. Dump existing table into a file:

    mysqldump -u [YOUR USER] -p'[YOUR PASS]' --single-transaction --database [Your DB Name] > [FILE-NAME-TO-DUMP.sql]

  2. Then copy the file to the server you want to create the database.

  3. Create your database that you'll be using on the new server
  4. Run the following

    cat [FILE-NAME-TO-DUMP.sql] | grep -vi "^USE" | grep -vi "^CREATE DATABASE" | mysql -u [YOUR USER] -p'[YOUR PASS]' --database [Your DB Name]

Upvotes: 0

Marius
Marius

Reputation: 15206

In Magento most of the tables are innodb (except for those 19 you found in your new installation). For innodb tables you cannot just copy the table files from the data folder. See this for more explanations.
If you cannot create a dump of the old db and restore it in your new xampp it may be lost.

Upvotes: 1

Related Questions