0

I have been given a MySQL database in the form of ibdata1, ib_logfile0, ib_logfile1, and a collection of .myi, .myd, and .frm files.

How would I go about 'attaching' this db to my local MySQL 5.1 installation? I found one advice to create a new directory in MySQL's data directory, but I can't find any such directory.

1
  • Could you add some information about the platform you're running MySQL on, and the source of these files?
    – BrianEss
    Sep 23, 2009 at 22:14

2 Answers 2

2

To find the 'data directory', which ended up under ApplicationData\AllUsers, I looked in 'my.ini' under the MySQL directory in Program Files. Then it was as simple (on the face of it) to copy all the .myi, .myd, and .frm files to a new directory under the data directory. Voila, instant DB.

2

There's two sets of files logistically speaking, some go one place and some go another. As BradyKelly mentions the first thing to do is find your "data" directory, usually specified in the my.ini file -- exactly where depends on your exact operating system and how you have MySQL installed. It may be in a system directory, a "data" directory underneath the unzipped/untarred download or a systemwide directory.

Given that data directory you need to get them back in the right place; the idb* files go right in the top level of 'data' itself: ibdata1, ib_logfile0, ib_logfile1

Underneath 'data' you will have subdirectories; one of these must be the core mysql/ subfolder that contains the associated .frm, .MYD, and .MYI files. Likewise any other database in this setup should have it's files in a subdirectory (mydatabase/) and it's assocated .frm, .MYD and .MYI files. You cannot just lump all these files in one subdirectory, they have to go back where they belong -- the person who gave them to you should have sent them to you with those subfolders intact.

I should note that this is about the worst way ever to try and recreate a mysql installation of data; the only reason you'd ever really do it this way is for disaster recovery where you had only these files to work with. If someone is trying to hand you a database they need to send the output of 'mysqldump' to you instead -- sending the raw files to a non-MySQL-savvy user is just asking for pain and heartache.

You mention you can't find your data directory -- start your MySQL one time before doing anything, then shut it down. Search your entire computer for "mysql" and you will find a folder with that exact name, that is the subdirectory inside 'data' that is the master MySQL user table and so on (i.e. it exists on every MySQL everwhere regardless of OS).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .