我將密碼存儲在變量$ db_pwd中,我想將它傳遞給shell腳本中的mysql_config_editor。我無法使用配置文件或db_pwd環境變量。使用shell中的變量將密碼傳遞給mysql_config_editor
我這樣做
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
和
expect
。但是,如果出現警告,例如「此路徑已存在,重寫(y/n)」,則會導致錯誤。即使在我將它用作第一個參數時,它們仍會給我發現變量未找到錯誤。是選項文件與MySQL配置編輯器兼容嗎?
沒有辦法做到這一點?或者我應該恢復使用mysql
代替mysql_config_editor的?
看到的是https:// stackoverflow.com/a/22513843/1497139 –