Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysqldump backup and restore to remote server

How can i use mysqldump to backup and restore database to a remote server?

Both have root access. I am using putty to perform this.

So far I tried the following:

mysqldump -u root -p >z*x311a!@ masdagn_joom15 | mysql \ -u root -p g2154hE6-AsXP --host=207.210.71.26 -C masdagn_joom15temp \g

but it refused

the local password is: >z*x311a!@

the remote password is: g2154hE6-AsXP

like image 766
manhag Avatar asked May 04 '10 20:05

manhag


2 Answers

This link provides information on backing up and restoring with mysqldump. It also gives some examples with a remote server.

The important commands from that link being:

backup:

mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

restore:

mysql -u root -p[root_password] [database_name] < dumpfilename.sql
like image 88
NebuSoft Avatar answered Oct 17 '22 05:10

NebuSoft


mysqldump --user=username --password=pwd db_name | bzip2 -c > /backup_dir/db_name.sql.bz2

you can embed this part in a script, afterward you can use FTP to transfer to the other location.

To restore, you can

bzip2 -d db_name.sql.bz2
mysql --user=username --password=pwd db_name < db_name.sql
like image 32
grokus Avatar answered Oct 17 '22 06:10

grokus