View Full Version : Move a MySQL Database from one host to another via SSH

07-17-2005, 07:25 AM
It's actually rather easy to do through ssh:

Login to old host:
First, dump the database to a file.
mysqldump database -uusername -ppassword > database.sql

then open an FTP session to your new host:

ncftp -uuser new-host

then put the file dump on the new server. Navigate to any appropriate directory first:

put database.sql

Exit twice, first to close the FTP session, and the SSH session:

ssh to new host (make sure the database actually exists!)

mysql database -uusername -p < database.sql
or simply mysql database -uusername -p
enter password
source database.sql