Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 would like to import a local file into my remote mysql database, which is residing on ec2. How would I accomplish the following:

$ ssh -i ~/.ssh/my_key.pem user@ip
$ mysql -u root localhost [ remote database ] < ~/dump.sql [ local file ]

Is there a way to do this with -L? How would I do this with one command here?

share|improve this question
cat ~/dump.sql | ssh -i ~/.ssh/my_key.pem user@ip mysql -u root [ remote database ]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.