Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:\folder\test.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:\folder\test.sql 

this command did not work.

How can I acheive this?

share|improve this question

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
share|improve this answer
    
I need to use the sql file I already have on my c:\ – Jkk May 23 '12 at 12:03
    
Take a look at WinSCP. – Silviu May 23 '12 at 13:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .