Restore MySQL database folder from a recovered Hard Disk

前端 未结 4 457

I was able to recover the database folder of MySQL server 5.5 of the corrupted operating system (Windows XP) at

C:\\Documents and Settings\\All Users\\Applica

相关标签:
4条回答
  • 2020-12-23 23:24

    @JohnWoo's answer is only for MYSIAM database engine. My answer is strictly for InnoDb storage engine,i.e., FRM and IBD files


    To recover InnoDb database, I followed exactly these steps successfully. Before pointing out the steps, I would like to tell you that I performed the recovery from recovered hard disk of Wndows XP and transferred it to Windows 7. So, this will help both windows xp and windows 7 users. So, the steps which I followed are :-

    • The MySQL server at both the machines MUST be stopped. Of course if the OS/hard disk crashed, the server at that machine is already stopped.
    • Now, MySQL installation is in 2 folders (for me at least) ->
      1. Program Files / Program Files (x86), and
      2. C:\Program Data\MySQL in windows 7 and C:\Users\All users\Application Data\MySQL in Windows XP. Note that Program Data(win7) as well as Application Data(WinXP) are hidden folders.
    • We are ONLY CONCERNED with the MySQL Server ** folder in the Application Data or Program Data folders. The Mysql folder in Program Files is of no use as it does not have your data.
    • Now Copy the my.ini file in MySQL Server ** folder.
    • Open the data folder and copy these files
      1. All the ib_logfile* files
      2. All the ibdata* files
      3. The database folders (that you want) containing .frm and .ibd files
    • Now, copy the files mentioned in the above two points in the destination machine. It is highly recommended to take a backup of the replaced files in the destination machine.
    • Now, restart the server. If you went right, you would restore your databases without any error.

    I would recommend you to have a look at the cold backup method for InnoDB at the mysql docs at dev.mysql.com/doc/mysql-backup-excerpt/5.5/en/innodb-backup.html

    0 讨论(0)
  • 2020-12-23 23:24

    I think MySQL's file management is pretty simple by default. Create a simple new database, and copy the recovered files into the mysql subfolder which is created in response, replacing any created database files. If that doesn't work, create a table in the new database to get a hint of what else might be needed.

    0 讨论(0)
  • 2020-12-23 23:32

    Ok, I got the answer to my own problem.

    Possible Scenario

    1. MYSQL program is corrupted and fail to start. Fresh install of MYSQL did not restore the data.
    2. Computer crashed but hard disk is still working
    3. Windows corrupted and fail to start up, but data is safe.

    For your information, in MYSQL, files with the extension MYD is the table data, FRM files is the table definition and MYI file is the table indices. There is also the ibdata file specified in the my.ini which is the InnoDB tablesapce files. You have to be an administrator, so that you can access Document and Settings folder or the Program Files folder.

    1. Open Window Explorer (Windows Key + E) or Open My Computer and go to the data folder where your database files reside.
    2. I would recommend you to copy all the folders in the data folder than just picking a few to copy. Copy the database folders and ibdata file (DO NOT COPY THE ib_logfile(x) files!) Note that the ibdata file might not be in the same location as the data files. To find out where it could be, read How to find MYSQL database files in Windows.
    3. Go over to the target computer, Open System Services. (Type services.msc at the Windows menu “Search Program and files” entry box)
    4. On the right panel of the Services window, scroll along the list and look for the name “MYSQL“. Select MYSQL and right mouse click and click . Once it has stopped, you will it’s status become blank instead of .
    5. Similarly look for the location of the data folder. Once you located it, I recommend you back up the folder or just rename it. Paste over the folders and ibdata file you have copied from the source computer to the data folder.
    6. Go back to the Services window and select back MYSQL. Right mouse click on it and click to resume the MYSQL service.
    7. Open MYSQL administrator and log on to your database server and you should be able to see your transferred database together with their data.
    0 讨论(0)
  • 2020-12-23 23:32

    I too faced the same problem and spent almost two to three days in solving the issue. I was fed up with all the other confusing answers I have seen. Finally, I have retrieved all my data from my old drive and can now successfully access it in my new Microsoft Server installation.

    This might help someone else.

    Problems faced:

    1. Finding database files in the old hard disk:
      Answer: Follow the instructions given in this link:
      https://www.quora.com/Where-is-the-database-stored-in-the-Microsoft-SQL-server/answer/Allu-Saiprudhvi?prompt_topic_bio=1

    2. If you can't open the folders in the old hard disk("The request could not be performed because of an I/O device error message"):
      Answer: Change the corresponding disk name. follow the instructions given in this link "follow the instructions given in this link"

    3. After getting database folders, first download the same version of Mysql server as in the old hard drive , you can check the version mentioned with the folder name itself.

    4. After downloading the same version, paste the database folders in the data folder as shown in the instruction 1 above.

    5. Stop and start the Mysql server in services:
      Answer: To know how to restart a mysql server follow the instruction given in the link:
      https://www.quora.com/How-do-I-start-the-MySQL-server-in-Windows-10/answer/Allu-Saiprudhvi?prompt_topic_bio=1

    6. Now you can check it, this should successfully make the data inside database accessible using SQL server.

    THANK YOU

    0 讨论(0)
提交回复
热议问题