0

from command line from my Mac terminal:

mysql --host=127.0.0.1 --port=3306 -uroot -p"mypass" wordpress -e "update users set user_pass = '$1$Hat7oFty$mA.L2vsQdD3MxvxAuDFKp0';"

completes successfully...

however.... only .L2vsQdD3MxvxAuDFKp0 is written to the user_pass field in every row. Whiskey Tango Foxtrot?

enter image description here

Needless to say when I issue update users set user_pass = '$1$Hat7oFty$mA.L2vsQdD3MxvxAuDFKp0'; directly to the DB from an application like DataGrip it takes the whole string correctly....

4
  • Is php code making the command line call? Commented Jul 30, 2018 at 18:38
  • No. Me, manually from my Mac terminal. Commented Jul 30, 2018 at 18:39
  • 1
    It's been a long time since I used bash. Could it be thinking $1$Hat7oFty$mA is a variable it should be substituting with? Commented Jul 30, 2018 at 18:40
  • 1
    hmmm didn't think of that. I guess I have to 'escape' it someohow Commented Jul 30, 2018 at 18:50

1 Answer 1

2

The $ are part of shell variables, which are unintentionally get replaced. You have to escape the $ character to keep it in the string as a literal $.

$ echo "$1$Hat7oFty$mA.L2vsQdD3MxvxAuDFKp0"
.L2vsQdD3MxvxAuDFKp0
$ echo "\$1\$Hat7oFty\$mA.L2vsQdD3MxvxAuDFKp0"
$1$Hat7oFty$mA.L2vsQdD3MxvxAuDFKp0
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.