我试图向远程服务器发送sql命令:‘=
命令:
`mysql -u videoeditor -p12345 testing -e "UPDATE testing.video SET rtsp_url = INSERT(rtsp_url, LENGTH(rtsp_url) - LOCATE('/', REVERSE(rtsp_url)) + 2, 0, '10101');"`
,我的完整命令是:
ssh user@serverIP 'mysql -u videoeditor -p12345 testing -e "UPDATE testing.video SET rtsp_url = INSERT(rtsp_url, LENGTH(rtsp_url) - LOCATE('/', REVERSE(rtsp_url)) + 2, 0, '10101');"'
但我的语法似乎错了
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 '/, REVERSE(rtsp_url)) + 2, 0, 10101)' at line 1
发布于 2015-06-21 08:02:47
SQL命令中的每个单引号应替换为“\”
发布于 2014-11-19 06:13:30
您很可能不得不转义sql字符串中的“,因为要使用ssh将它们包装在”中。
ssh user@serverIP 'mysql -u videoeditor -p12345 testing -e "UPDATE testing.video SET rtsp_url = INSERT(rtsp_url, LENGTH(rtsp_url) - LOCATE(\'/\', REVERSE(rtsp_url)) + 2, 0, \'10101\');"'
发布于 2015-06-21 09:02:13
你在传递主机名吗。请尝试格式为
mysql -p -u <mysql_username> -h <mysql_server_ip> -e "<update query>"
确保从远程服务器到MySQL服务器有必要的权限
https://stackoverflow.com/questions/27010115
复制相似问题