1

Im trying to run run write a command where I can execute remote queries stored local.

I was trying:

drush @remote.master sqlq < src/sql/data.sql

but no luck, also tried the option --file=path/to/file but it's only for remote files :(

Any ideas?

1
  • "but no luck" - please explain. What you expected to happen? What really happened?
    – Mołot
    Commented Aug 13, 2015 at 15:39

2 Answers 2

1

Try this: cat src/sql/data.sql | drush @remote.master sql-cli

4
  • This work, but: 1. You need to add: 'ssh-options' => '-t' to drush alias 2. You need to add: ; and new line at the end of you sql files Thanks! I can't put line breacks on this box!!!!
    – Nah
    Commented Aug 14, 2015 at 10:40
  • Any idea how I could concatenate the ;\n at the end, on the same command so I can have "clean" sql files?
    – Nah
    Commented Aug 14, 2015 at 10:48
  • forget about -t option, the message Pseudo-terminal will not be allocated because stdin is not a terminal. don't interfere with the sql actually excecuting, but -t option it mess with other drush works. Just remember to add ; at the end of sql.
    – Nah
    Commented Aug 14, 2015 at 11:39
  • Not sure why your source sql file would be missing a trailing ; if the remote side needs it, but you could always add one on via (cat src/sql/data.sql && echo ";") | drush ... if you needed to. Commented Aug 14, 2015 at 13:13
1

you should try with other command:

drush sql-sync --source-dump=src/sql/data.sql --target-db-url=mysql://remoteusername:remotepass@remoteserver/remotedatabase
2
  • can't use that solution as I don't have direct access to mysql, but trough drush aliased ssh connection :(
    – Nah
    Commented Aug 14, 2015 at 10:45
  • In that case, I think the best is copy the dump via SCP and restore it. Commented Aug 17, 2015 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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