Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rebuild table from binaries

Status
Not open for further replies.

scoopmcloop

Technical User
Sep 1, 2003
3
AU
I would like to rebuild a MySQL table from binary files.
I have the binary files for my_table in the files my_table.frm, my_table.MYD and my_table.MYI.
I would like to generate an SQL statement to export the data.
I created my_db on my local machine and then created the table my_table. This automatically created 3 files in /var/lib/mysql/my_db which are my_table.frm, my_table.MYD and my_table.MYI. I deleted these files.
Then I copied the original files (the ones with the data I need) into /var/lib/mysql/my_db so once again it contained my_table .frm, .MYD and .MYI files.
When I logged into mysql and ran DESCRIBE my_table; i got this message:
Code:
ERROR 1017: Can't find file: './my_db/my_table.frm' (errno: 13)
How can I get the data out of these binary files?
 
I RTFM the MySQL Manual and tried this:
mysql> restore table my_table from '/path/to/backup/directory';
and i got this:

+------------------+---------+----------+--------------------------+
| Table | Op | Msg_type | Msg_text |
+------------------+---------+----------+--------------------------+
| my_table | restore | error | Failed copying .frm file |
+------------------+---------+----------+--------------------------+
1 row in set (0.00 sec)
Any ideas?
 
Don't use any utility from the MySQL Prompt.

Just copy the appropriate files into the correct database directory

if the table is called countries you will have to copy

countries.frm
countries.Myi
countries.MyD

in the directory related to your database(if you use RH it should be /var/lib/mysql/DBName/). You may need to issue a GRANT command from MySQL Prompt to make those tables writable if they are read only after transfering them.

Bye

Qatqat







Life is what happens when you are making other plans.
 
Thanx Qatqat, I moved the files into /the/directory and then did
Code:
mysql > restore table my_table from '/the/directory';
and that worked.
I think the problem was I had not unpacked the .frm .MYD and .MYI files properly from the tarball.
Solved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top