Tuesday, December 6, 2011

Download an SQL file from a remote server and import it into a localhost database in Ubuntu Linux

CONNECT TO THE REMOTE SERVER USING SSH


If you don't know where the file is, and you don't have a graphical browser for the remote server, log in and browse around from the command line like this:

ssh -L 3307:localhost:3306 {your remote account}@{your server}.com
password: {your remote password}
ls
cd {some directory}
ls

GET THE FILE


Once you have the remote path and name of the file you want, exit ssh and issue the scp command from your local command line like this:

scp {your remote account}@{your server}.com:{file path}/{file name} .
password: {your password to the remote account}

IMPORT THE FILE


Once you have the file local, import it into an existing mysql table like this:

mysql -D{the database name} -u{the database user name -p < {the path and file name}

No comments: