You are Here:
FAQ
Scripting & Programming
MySQL
Article #14
|
How to restore a Database from an SQL dump that has been GZipedThe following PHP Script will restore a backup of a MySQL Database in a GZip file Please noteThe SQL dump must be called
dump.sql.gz and must be on the DOCUMENT_ROOT
<?php
// Please Enter your Database details
$host= 'dbxx.oneandone.co.uk';
$user= 'dbxxxxxx';
$pass= 'xxxxxxxx';
$db= 'dbxxxxxxx';
// GZip is unpacked and feed into the Database
system(sprintf(
'gunzip -c %s/dumpDB.sql.gz | mysql -h %s -u %s -p%s %s',
getenv('DOCUMENT_ROOT'),
$host,
$user,
$pass,
$db
));
echo '+DONE';
?>
If the script times out then you may have to do this using the SSH Command line interface. Restore by SSHIf you have a Business Pro Package, Professional Package or a Managed Server then you can also do this using the Secure Shell interface. Log in and run the following commands.
(******** = your password) If the SQL Dump is GZiped then you can use the following command:
For more information please see http://dev.mysql.com/doc/ |
© 2007 1&1 Internet Ltd - About 1&1 Internet