0

ssh root@ip "mysql -uroot -p -e 'grant all on wordpress.* to firaswp@'ip' identified by 'password123';'"

however, when I input grant all on wordpress.* to firaswp@'54.87.224.199' identified by 'password123'; in mysql daemon it works fine..

does anyone know why this wouldn't be working? the syntax should be fine - if i remove "identified by 'password123', it works. Thanks!

firas
  • 5
  • 3
  • You have a classical problem of quotation within quotation. [You need escaping](http://stackoverflow.com/questions/1250079/escaping-single-quotes-within-single-quoted-strings). – RandomSeed Jul 20 '14 at 11:04
  • Still a bit confusing, primarily, because I used single quotes without 'password123', and it work's fine. It's only after adding "identified by 'password'; in that the syntax breaks. – firas Jul 20 '14 at 11:30

1 Answers1

0

I am using this, and it works for me:

ssh root@ip "mysql --user=user --password=pass database -e 'query'"

Your script also look working but don't use ; in command.

Justas Pukys
  • 124
  • 1
  • 1
  • 8
  • I just tried it again - it didn't work, I got ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'password' at line 1 - I did remove the ;, too. – firas Jul 20 '14 at 13:13