3

I have a back up-of a MySQL database which is contained in a .tar.gz file - I need to restore it.

I've never had to do this before. The only way I can access the database is through phpmyadmin. There is an 'import' feature in phpmyadmin, but this doesn't accept files in the tar.gz format, only sql.

Is there any way I can convert from .tar.gz to sql? I know I can upload from an sql file without a problem.

I don't have access to any 'back-end' stuff on the web-server, so I'm limited with what I can do locally on my PC.

Any help is much appreciated.

3
  • Its on my pc, but I could upload it to the server. I can run my own php scripts on the server if that helps. Jun 30, 2013 at 15:57
  • I've tried extracting it on my PC through two stages: 1) FILENAME.tar.gz > extracts to one file: FILENAME.tar 2) FILENAME.tar > extracts to 3 sub folders: "PaxHeader", "mysql" and "HPM" (the database name) all containing various files. The "HPM" folders contain files named after the DB table names with extensions like ".MYD" and ".FRM" and ".MYI" I was hoping for 1 sql file. Jun 30, 2013 at 16:18
  • 2
    It sounds like someone sent you a copy of the MySQL data directory instead of a backup taken with mysqldump. This isn't a valid way to back up MySQL unless it's stopped or flushed and globally read-locked first, so the backup might be corrupt. Depending on the MySQL setup on the source, you might be able to just copy the HPM folder to your MySQL data directory. This could fail for a lot of reasons, though, for example if the backup was taken while MySQL was running, or if the source database has InnoDB tables without innodb_file_per_table enabled. Jun 30, 2013 at 18:57

2 Answers 2

1

Actually it seems a backup by copy files (as tables are myisam tables) not a mysqldump. So you just need to untar this compressed file by below command on linux-

$ untar -zxvf your_backup.tar.gz . 

Note: Please run this command from the directory where your backup file exist and it will provide you normal backup also in same directory.

Now you can simply copy these files (*.frm, *.MYI, *.MYD) to your database directory in which Database you want to restore them and it should work.

Note: if there is any permission related issue then use below command to make sure mysql can use these files/tables.

$ chown -R mysql:mysql /path_till_your_db_directory/* 
1
  • If untar is unavailable you can also just use tar i.e. 'tar xvzf <file>'
    – gnuchu
    Sep 3, 2015 at 11:07
1

Just unzip it using winrar. And you will get sql file. Thanks

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.