By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,080 Members | 1,817 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,080 IT Pros & Developers. It's quick & easy.

How do I restore a backup in mysql?

P: n/a
I successfully take backups of my database with this php code:

$command = "mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname |
gzip $backupfile.gz";

$dummy = system($command, $retval);

But I can not find the code for restoring a backup file. How is it
done?

Kind regards,

Jan Nordgreen
Jun 2 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On May 12, 5:22*pm, damezumari <jannordgr...@gmail.comwrote:
I successfully take backups of my database with this php code:

$command = "mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname |
gzip $backupfile.gz";

$dummy = system($command, $retval);

But I can not find the code for restoring a backup file. How is it
done?

just copy the content in that backup file and paste it in mysql
console thats all.
or do this
$mysql -u username -p database < path/to/backup.sql

you have to do google search before you ask anything in mailing list .
Jun 2 '08 #2

P: n/a
I want to restore a .gz file not a .sql file.

I have tried:

$command = "mysql -u$dbuser -p$dbpass $dbname < $backupfile.gz";
$dummy = system($command, $retval);

($dummy === false) returns false and retval returns 1, but the
database is not restored.

What am I doing wrong?

Kind regards,

Jan Nordgreen
Jun 2 '08 #3

P: n/a
On Tue, 13 May 2008 08:27:36 -0700, damezumari wrote:
I want to restore a .gz file not a .sql file.

I have tried:

$command = "mysql -u$dbuser -p$dbpass $dbname < $backupfile.gz"; $dummy
= system($command, $retval);

($dummy === false) returns false and retval returns 1, but the database
is not restored.

What am I doing wrong?

Kind regards,
The .qz file is a compressed tar file.

tar xvfz <your file>.gz

Into a working directory and then perform the restore you with the plain
text file.

--
"Remain calm, we're here to protect you!"

Jun 2 '08 #4

P: n/a
damezumari escribió:
$command = "mysql -u$dbuser -p$dbpass $dbname < $backupfile.gz";
If OS is Unix, try:

$command = "gunzip --to-stdout $backupfile.gz | mysql -u$dbuser
-p$dbpass $dbname";

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jun 2 '08 #5

P: n/a
Alvaro, thank you! It worked like a dream. My server is running Linux.

Kind regards,

Jan Nordgreen
Jun 2 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.