Copying MySQL data files to another computer

In case I don't have a backup of database and I have just the data files in the Data folder left. How to attach those Data files to a fresh installation of MySQL?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

UmeshSenior Principal Technical Support EngineerCommented:
Hi Khare,

Could you please tell me these so that I can tell you the best possible way

1. OS
2. InnoDB tables or MyISAM tables used?
3. If InnoDB then
  Files per table or single datafile (tablespace)?

rpkhareAuthor Commented:
(1) Win XP SP2
(2) InnoDB
(3) Default
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

UmeshSenior Principal Technical Support EngineerCommented:

 If you are able to shut down your MySQL server, you can make a binary backup that consists of all files used by InnoDB to manage its tables. Use the following procedure:

Binary copying from source server

   1. Shut down your MySQL server and make sure that it shuts down without errors.
   2. Copy all your data files (ibdata files and .ibd files) into a safe place.
   3. Copy all your ib_logfile files to a safe place.
   4. Copy your my.cnf configuration file or files to a safe place.
   5. Copy all the .frm files for your InnoDB tables to a safe place.

On target server(Fresh installation)

Youll have to shut down MySQL, copy the files into place, and then restart.

You also need to ensure that InnoDBs transaction log files match its tablespace files. If the files dont matchfor example, if you replace the tablespace files but not the transaction log filesInnoDB may
refuse to start. This is one reason its crucial to back up the transaction log along
with the data files.

Also, going forward make sure youre using the newer InnoDB file-per-table feature (innodb_file_per_table). that makes life bit easier when restoring fever tables..

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rpkhareAuthor Commented:
Where the "ibdata" and ".ibd" files located? And, where is the transaction log located?
UmeshSenior Principal Technical Support EngineerCommented:
>>Where the "ibdata" and ".ibd" files located? And, where is the transaction log located?

ibdata & ib_logfile  - should be in mysql/data/*
.ibd - avail only if  InnoDB file-per-table is used.

rpkhareAuthor Commented:
Thanks I will try it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.