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

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?

Super User Asked by Jkk on December 28, 2020

1 Answers

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 [email protected]:/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!

Related Questions

Mouse on windows only works properly with USB hub

0  Asked on November 16, 2021 by chubby-unicorn


PC startup issue: Can a video card short damage a motherboard?

1  Asked on November 16, 2021 by jeffrey-g-jarjoura


Make internal card reader readable to BIOS

1  Asked on November 14, 2021 by starkers


Turn on mobile hotspot on startup Windows 10

2  Asked on November 14, 2021 by george-dimitriadis


Router technologies to bypass NAT?

1  Asked on November 14, 2021


How to troubleshoot miracast on windows 10 laptop?

1  Asked on November 14, 2021 by jonesome-reinstate-monica


How to set +60Hz refresh rate with an Intel CPU?

3  Asked on November 14, 2021 by user1066981


Ask a Question

Get help from others!

© 2022 All rights reserved.