[英]how do I parameterize mysql login when using .my.cnf
I have the following shell script that relies on $HOME/.my.cnf to supply the password. 我有以下依赖$ HOME / .my.cnf的shell脚本来提供密码。 The two calls to mysql are equivalent, but the second one prompts for a password whereas the first does not.
对mysql的两个调用是等效的,但是第二个要求输入密码,而第一个不要求输入密码。 I am trying to write some shell scripts with the connectivity details parameterized except for password.
我正在尝试编写一些shell脚本,其中将参数设置为连接详细信息,密码除外。 I tried using #!/bin/sh.
我尝试使用#!/ bin / sh。 There is no whitespace after any of the parameters.
任何参数之后都没有空格。 Any suggestions?
有什么建议么?
$ cat processlist-state.sh
#!/bin/bash
export HOSTNAME=mysql-us-east-1-123456789.abcdefghijklm.us-east-1.rds.amazonaws.com
export PORT=3306
export USERNAME=master_user
mysql -h mysql-us-east-1-123456789.abcdefghijklm.us-east-1.rds.amazonaws.com -P 3306 -u master_user -e "show processlist"
mysql -h ${HOSTNAME} -p ${PORT} -u ${USERNAME} -e "show processlist"
$ cat $HOME/.my.cnf
[client]
password=password
-p in the second call forces the password prompt. 第二个调用中的-p强制输入密码提示。
-p = ask for password
-p =要求输入密码
-P = connection port
-P =连接端口
-p{PASSWORD} = use {PASSWORD} from commandline as password
-p {PASSWORD} =从命令行使用{PASSWORD}作为密码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.