In this tutorial I will show you how to backup remote MySQL database using SSH.
We are assuming that the remote server uses
localhost as hostname. Use the proper host address if the hostname is not
Step 1: Connect to the Server
Firstly, you need to connect to the remote server. Use the following command to connect to it using a SSH connection.
ssh -f -L3310:localhost:3306 <username>@<servername> -N
For eg. use the following command to connect to binodbrothers.in using maskaravivek as the user.
ssh -f -L3310:localhost:3306 email@example.com -N
Step 2: Use mysqldump to Dump Tables
Next, use the
mysqldump command to backup your tables.
mysqldump -P 3310 -h 127.0.0.1 -u <user_name> -p <database_name> <table_name> > /Users/vivek/Documents/<filename>.txt
For eg. use the following command to dump
StoryTags table from
stories_admin having the admin previlages.
/usr/local/mysql/bin/mysqldump -P 3310 -h 127.0.0.1 -u stories_admin -p stories_db StoryTags > /Users/vivek/Documents/StoryTags.txt
The screenshot below shows
mysqldump being used to dump a MySQL table.
This content has been helpful to you?
Thanks for contributing!