简体   繁体   English

为什么通过ssh的mysql命令不提示输入密码?

[英]Why does mysql command over ssh does not prompt for password?

I'm attempting to run a command like the following: 我正在尝试运行如下命令:

ssh user@host 'mysql -u dbuser -p database < ~/data.sql'

I'm expecting it to prompt me a password like it normally would if you're on that host. 我希望它像在主机上时一样提示我输入密码。

However, it does not do that. 但是,它不会这样做。 Is there an ssh argument I'm missing or something? 我是否缺少ssh参数?

Another thing to note is that if you remove the < ~/data.sql , the prompt does appear as expected. 还要注意的另一件事是,如果删除< ~/data.sql ,则提示确实会出现。

您需要创建一个伪终端,以便mysql可以从/dev/tty而不是标准输入中读取:

ssh -t user@host 'mysql -u dbuser -p database < ~/data.sql'

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

相关问题 命令提示符不显示宽MySQL表 - Command prompt does not show wide MySQL tables 为什么 Windows mysql 客户端在通过命令提示符使用 INTO OUTFILE 时需要正斜杠? - Why does the Windows mysql client requrie forward slashes when using INTO OUTFILE via the command prompt? MySQL命令提示符不需要密码 - MySQL command prompt doesnt require password 使用命令提示符时,MySQL不需要密码 - Mysql requires no password when using command prompt 在WampServer上使用命令提示符设置MySQL根密码 - Set MySQL root password with command prompt on WampServer 使用MySQL的远程SSH命令不起作用,但该语句本身起作用 - Remote SSH command with MySQL won't work, but the statement itself does 为什么mysql的安装程序不要求我在Ubuntu 16上设置密码? - Why does the installer for mysql not ask me to setup a password on Ubuntu 16? 从 .NET 代码通过 SSH.NET ForwardedPortLocal 连接到 MySQL 不起作用 - Connection to MySQL from .NET code over an SSH.NET ForwardedPortLocal does not work 命令提示符不允许我同时使用 docker 和 mysql 函数在 docker 容器中创建 sql 数据库 - command prompt does not allow me to use docker and mysql functions at the same time for creating an sql database in docker container 为什么脚本不跳过MySQL数据插入? - Why does script not skip over MySQL data insertion?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM