简体   繁体   English

mysql命令行sql执行之谜,仅考虑字符串的一部分

[英]mysql command line sql execution mystery, only part of the string is considered

from command line from my Mac terminal: 从Mac终端的命令行中:

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. 但是....每行仅将.L2vsQdD3MxvxAuDFKp0写入到user_pass字段中。 Whiskey Tango Foxtrot? 威士忌探戈狐步舞?

在此处输入图片说明

Needless to say when I issue update users set user_pass = '$1$Hat7oFty$mA.L2vsQdD3MxvxAuDFKp0'; 不用说,当我发布update users set user_pass = '$1$Hat7oFty$mA.L2vsQdD3MxvxAuDFKp0'; directly to the DB from an application like DataGrip it takes the whole string correctly.... 直接从诸如DataGrip之类的应用程序发送到DB,它正确地接收了整个字符串。

The $ are part of shell variables, which are unintentionally get replaced. $是shell变量的一部分,会无意间被替换。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM