Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restore MySQL database folder from a recovered Hard Disk

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\Application Data\MySQL\MySQL Server 5.5\data\

How can I manually restore it to the new MySQL Server? When I open the folder, I found out several folders and I believed those are the databases. I didn't file any SQL Files.

like image 736
John Woo Avatar asked May 21 '12 06:05

John Woo


People also ask

Can I copy MySQL data directory?

Copying the entire data folder If you are copying the entire database installation, so, all of the databases and the contents of every database, you can just shut down mysqld, zip up your entire MySQL data directory, and copy it to the new server's data directory.


1 Answers

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.
like image 143
John Woo Avatar answered Oct 07 '22 03:10

John Woo