Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recovering mysql database from data folder backup

I have uninstalled the old XAMPP and deleted all of the content of d:\xampp folder and installed the new one. When I copy my backup folder (with the name of my database, containing all .frm and .opt files) to the D:\xampp\mysql\data, the database shows in the list in phpmyadmin but it has no tables and data. What I've done wrong?

like image 553
Alireza Noori Avatar asked Jan 28 '12 00:01

Alireza Noori


People also ask

Can I copy MySQL data directory?

You have to shut down mysql server (which is not good, if it's a production server) You have to make sure the permission of data (mysql) directory is same as the previous one.


2 Answers

Here's how I dealt with this kind of situation:

  1. Stop the Apache and MySql services from xampp control panel.
  2. Back up (just in case), then delete the data folder from your new xampp installation folder <physical_drive>/xampp/mysql.

    (The data folder contains the schema/table definitions (.frm files) for your tables.)

  3. Copy the data folder from your previous xampp folder (or the backup) under mysql and paste it to the new location (i.e. <physical_drive>/xampp/mysql).
  4. Now start the Apache and MySql services from the xampp control panel.

There you go, the tables should show up with their structures as you click on them.

Note: Make sure you leave the bin folder under your xampp installation folder untouched.

like image 132
Ahmad Baktash Hayeri Avatar answered Sep 29 '22 18:09

Ahmad Baktash Hayeri


It is possible, I found out a solution:

  1. Install new xampp
  2. Copy your old database folder from xampp\mysql\data\databasefolder to Paste in your running xampp folder
    C:\xampp\mysql\data
  3. After that stop mysql and apache service then backup your running xampp files ib_logfile0,ib_logfile1 and ibdata1 and store in safe place
  4. Then Copy same file (ib_logfile0,ib_logfile1 and ibdata1) from old xampp\mysql\data\ and paste in your running xampp server C:\xampp\mysql\data\
  5. Start mysql and apache service Open CMD Fire command C:\xampp\mysql\bin>mysqldump -u dbusername -p dbpassword dbname>D:\exportdb.sql
  6. stop mysql and apache service and restore your main ib_logfile0,ib_logfile1 and ibdata1 file (check Step 3)
  7. after than again start service and open http://localhost/phpmyadmin/ and import database backup from D:\exportdb.sql Now your backup is working :)
like image 31
Rahul Shewale Avatar answered Sep 29 '22 18:09

Rahul Shewale