I have password stored in a variable $db_pwd and I want to pass it to mysql_config_editor in a shell script. I can not use config file or db_pwd environment variable.
I am doing this
mysql_config_editor set --login-path=local --host=localhost --user=username --password
(https://stackoverflow.com/a/20854048/6487831) .
What it does is ask for password "Enter Password", but I wish to supply the password using variable.
I tried this :
mysql_config_editor set --login-path=local --host=localhost --user=username --password $db_pwd
and
mysql_config_editor set --login-path=local --host=localhost --user=username --password | echo $db_pwd
and
echo "$db_pwd" | mysql_config_editor set --login-path=local --host=localhost --user=username --password
and
expect
. But this leads to error in case there are warnings like "This path already exists, rewrite (y/n).- options file, but they still give me variable not found error even when I am using it as the first argument. Is options file compatible with mysql config editor?
Any way to do this? Or should I revert to using mysql
instead of mysql_config_editor?