Add to Favourites Add to Favourites    Print this Article Print this Article

How to manually restore a database.gz file via ssh

If you've got a very large database.gz file, it's often easier to upload first, and restore in a seperate step.
1) Once you've got the gz file uploaded onto your server, login to ssh and cd to the path where the file is located.

cd /path/to/your/gz/file


2) The next step is to extract the gz file into it's raw sql form (text).  To do that, use the gunzip program, eg:

/usr/bin/gunzip < database.gz database.sql

This should have extracted the gz file into the sql in plain text form.

3) Before you can load the sql file into mysql, you'll need to ensure you have the database and database user created.  Go to User Level -> MySQL Management, and create the empty database normally through DA.

4) To restore the sql to mysql, run the following command:

mysql -udbusername -ppassword username_dbname < database.sql

where you'd replace the bold entries with the applicable values.

This could can be combined into a more simple pipe form to offer fewer steps, but this method has the benefit of being able to show you any errors at each step to ensure everything is as it should be.

Was this answer helpful?

Also Read