How To Copy MySQL Database From One Server To Another Remote Server


run mysqldump to create a database copy and backups as follows:

$ mysqldump -u user -p db-name > db-name.out

Copy db-name.out file using sftp/ssh to remote MySQL server:

$ scp db-name.out user@yourserver.com:/backup

Restore database at remote server (login over ssh):

$ mysql -u user -p db-name < db-name.out

OR

$ mysql -u user -p 'password' db-name < db-name.out

copy database from one computer/server to another using ssh or mysql client.

ssh if you don’t have direct access to remote mysql server (secure method):

$ mysqldump db-name | ssh user@yourserver.com mysql db-name

OR

$ mysqldump -u username -p'password' db-name | ssh user@yourserver.com mysql -u username -p'password db-name

You can just copy table called  foo to remote database (and remote mysql server yourserver.com) called bar using same syntax:

$ mysqldump db-name foo | ssh user@yourserver.com mysql bar

OR

$ mysqldump -u user -p'password' db-name foo | ssh user@yourserver.com mysql -u user -p'password' db-name foo

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: