- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我将密码存储在变量 $db_pwd 中,我想将它传递给 shell 脚本中的 mysql_config_editor。我不能使用配置文件或 db_pwd 环境变量。
我在做这个
mysql_config_editor set --login-path=local --host=localhost --user=username --password
(https://stackoverflow.com/a/20854048/6487831)。
它的作用是要求输入密码“Enter Password”,但我希望使用变量提供密码。
我试过这个:
mysql_config_editor set --login-path=local --host=localhost --user=username --password $db_pwd
和
mysql_config_editor set --login-path=local --host=localhost --user=username --password | echo $db_pwd
和
echo "$db_pwd" | mysql_config_editor set --login-path=local --host=localhost --user=username --password
和
期待
。但这会导致错误,以防出现“此路径已存在,重写 (y/n)”之类的警告。有什么办法吗?或者我应该恢复使用 mysql
而不是 mysql_config_editor?
最佳答案
我发现当没有 TTY 时,其他建议的答案不起作用。所以我使用了这个 bash 脚本,它可以在 Terraform/ssh 等没有终端的地方工作:
#!/bin/bash
if [ $# -ne 4 ]; then
echo "Incorrect number of input arguments: $0 $*"
echo "Usage: $0 <login> <host> <username> <password>"
echo "Example: $0 test 10.1.2.3 myuser mypassword"
exit 1
fi
login=$1
host=$2
user=$3
pass=$4
unbuffer expect -c "
spawn mysql_config_editor set --login-path=$login --host=$host --user=$user --password
expect -nocase \"Enter password:\" {send \"$pass\r\"; interact}
"
测试它:
./mysql_config.sh login 10.1.2.3 myuser mypass < /dev/null
关于mysql - 在 shell 中使用变量将密码传递给 mysql_config_editor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42232310/
我跑了sudo apt-get install mysql-client它安装正确。然后我跑了mysql_config_editor print我得到了 mysql_config_editor: no
在运行Windows 7 pro的计算机上使用mysql_config_editor,因此密码不需要放入批处理文件中 在 Windows 7 Pro 上运行 MySql 版本 5.7。我正在学习MyS
您好,我正在尝试直接在我的 Dockerfile 中使用 mysql_config_editor 工具: FROM mysql RUN mysql_config_editor set --login-
我已经升级到 mysql 5.6.13 并且想尝试新的 --login-path 特性。 我使用 "mysql_config_editor set --login-path=local --host=
我将密码存储在变量 $db_pwd 中,我想将它传递给 shell 脚本中的 mysql_config_editor。我不能使用配置文件或 db_pwd 环境变量。 我在做这个 mysql_confi
我最近试图让我的服务器连接到 mysql_config_editor。我使用 mysql_config_editor set --login-path=FailOverTest --host=loca
我是一名优秀的程序员,十分优秀!