Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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.