Sometimes you need to copy a database from a live or staging system to a local host. For a small MySQL database, you can use the following lines:

$ ssh user@hostname
user@hostname:~$ mysqldump -u db_user -p dbname_production > db_backup
user@hostname:~$ exit
$ scp user@hostname:~/db_backup .
$ mysql -u db_user -p dbname_production < db_backup
Advertisements