命令:
ssh xxx.xxx.xxx.xxx \"mysql -u root -password \\\"grant all privileges on rcf_275d315.* to rfc_user@localhost identified by \'W27j453frxrff23\'\\\"\"
给我一个错误:
bash: mysql -u root -p97yf2beiru3trf289 "grant all privileges on rcf_275d315.* to rfc_user@localhost identified by 'W27j453frxrff23'": command not found
当我复制 bash 返回的字符串时,在本地运行它可以正常工作。粘贴在远程服务上时也可以使用。
由于某种原因,它不能通过 ssh 工作,并返回错误:
mysql -u root -p97yf2beiru3trf289 "grant all privileges on rcf_275d315.* to rfc_user@localhost identified by 'W27j453frxrff23'": command not found
更新:
我尝试了一些变化,但没有成功:
ssh xxx.xxx.xxx.xxx \"mysql -u root -pBOY8o7ubio87gubip7 \\\"grant all privileges on rfc_275d315.* to rfc_user identified by \'KUG34dY976fyvc768g\'\\\"\"
结果:
bash: mysql -u root -pBOY8o7ubio87gubip7 "grant all privileges on rfc_275d315.* to rfc_user identified by 'KUG34dY976fyvc768g'": command not found
ssh xxx.xxx.xxx.xxx \"mysql -u root -pBOY8o7ubio87gubip7 \\"grant all privileges on rfc_275d315.* to rfc_user identified by \'KUG34dY976fyvc768g\'\\"\"
结果:
bash: -c: line 0: unexpected EOF while looking for matching `"'
bash: -c: line 1: syntax error: unexpected end of file
ssh xxx.xxx.xxx.xxx mysql -u root -pBOY8o7ubio87gubip7 \\"grant all privileges on rfc_275d315.* to rfc_user identified by \'KUG34dY976fyvc768g\'\\"
结果:
mysql Ver 14.14 Distrib 5.1.66, for redhat-linux-gnu (x86_64) using readline 5.1
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
拥有者。
Usage: mysql [OPTIONS] [database]
-?, --help Display this help and exit.
ssh xxx.xxx.xxx.xxx mysql -u root -pBOY8o7ubio87gubip7 \\\"grant all privileges on rfc_275d315.* to rfc_user identified by \'KUG34dY976fyvc768g\'\\\"
结果:
mysql Ver 14.14 Distrib 5.1.66, for redhat-linux-gnu (x86_64) using readline 5.1
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
拥有者。
Usage: mysql [OPTIONS] [database]
-?, --help Display this help and exit.
仍然,不要问题出在哪里。谢谢你的帮助。
更新:当 echo 保存到文件时:ssh xxx.xxx.xxx.xxx "echo mysql -u root -piugiu -e \\"将 rfc_275d315.* 上的所有权限授予由 \'in76bn6bgb876n\'\\" > rfc 标识的 rfc_user /echo.txt"
我在文件中得到这个:mysql -u root -piugiu -e“将 rfc_275d315.* 上的所有权限授予由‘in76bn6bgb876n’标识的 rfc_user”
这是正确的命令,当复制并粘贴到远程服务器上的命令行时,它可以正常工作。
当 echo 被删除时: ssh xxx.xxx.xxx.xxx "mysql -u root -piugiu -e \\"将 rfc_275d315.* 上的所有权限授予由 \'in76bn6bgb876n\'\\" > rfc/echo.txt 标识的 rfc_user "
文本文件包含有关 mysql 使用的信息: Usage: mysql [OPTIONS] [database] -?, --help 显示此帮助并退出。