First , connect to the remote mysql instance via an ssh tunnel on port 10000
ssh -f -N -L 10000:localhost:3306 remoteuser@remoteserver
Try out the connection via the mysql client
mysql -u remote_sql_user --password=remote_sql_pass -h 127.0.0.1 -P 10000 remote_db_name
Type "show databases" , and you should see a list of databases available on the remote sql instance.
To dump out a database locally, quit the mysql client, and type :
mysqldump --host=127.0.0.1 --port=10000 --user=remote_sql_user ==password="remote_sql_pass" --verbose > /your_local_directory/name_of_db.sql
For very large db dumps, it is faster to use zcat & gzip, then pipe to mysql :
gzip name_of_db.sql
zcat name_of_db.sql.gz | mysql -u local_sql_user --password=local_sql_pass --database=name_of_db
No comments:
Post a Comment