I am having a little trouble with a bash script im writing, i can run the individual commands in terminal and it works just fine, but running from a bash script is returning the error;
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
The bash script is as follows;
#!/bin/bash
ssh user@myhost.com << EOF
/usr/bin/mysql -h localhost -u root -p_kHaTX(!G_$=Y5Xa
show databases;
EOF
I have tried to also wrap the password in '' like so
/usr/bin/mysql -h localhost -u root -p'_kHaTX(!G_$=Y5Xa'
and still nothing
But if I run the commands myself through the terminal, it all works just fine
Any help would be greatly appreciated.
Thanks
1条答案
按热度按时间ycggw6v21#
To resolve the error, and for security purposes also, store the password in a separate file, let's say:
Then pass the password as variable: