a stupid question about backup and recover mysql database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
php12342005
Forum Commoner
Posts: 79
Joined: Mon Mar 21, 2005 3:35 am

a stupid question about backup and recover mysql database

Post by php12342005 »

I test to backup my database - download to my PC as a file (host does this), i.e. main.gz.

questions:
1. what does a gz file mean? is it just a compressed file? is it readable (undestood) by us? can I view TABLEs, FIELDs and data from the gz file?
2. how to recover my database from the main.gz file?

I am new to mysql database.

thanks
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

.gz files are a compressed file, like a .zip or a .tar. You will need to "ungz" the file before you can view it. Once you do, you'll have a dump of your database (a .sql file) which you can then import into MySQL to "recover" your data.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Usually, databases are backed up using the mysqldump program. That program will give you a raw .sql file. Someone has to then compress the file into a .gz, so that the file is smaller. If you're running on linux, the command to unzip that will be:

Code: Select all

gunzip myFile.gz
You will then likely be given that .sql file. To import it back into mysql, call:

Code: Select all

mysql -u root -p rootPass databaseName < myUncompressedFile.sql
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply