TransWikia.com

Import a local SQL File To a Remote Server Using SSH Tunnel

Super User Asked by Jkk on December 28, 2020

I have a connection between my localhost and a remote server using putty SSH tunnel.

Thats fine.

Now I need a command to get the sql file on my local machine i.e. c:foldertest.sql and import it into mysql on the remote server

I thought maybe…

mysql -u username -p testpass -h localhost -P 3307 prefix_testdb

then do a command like

mysql -p -u username database_name < c:foldertest.sql 

this command did not work.

How can I acheive this?

One Answer

Before anything, you need to export your database:

mysqldump -p --opt dbname >test.sql

Using SCP, copy over SSH your file:

scp test.sql user@domain:/path/to/test.sql

And import it (you need to create dbname before):

mysql -p -D dbname <test.sql

Answered by Silviu on December 28, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP