I have about 20 different MySQL instances that I'd like to easily connect to without having to input the whole address, username, and crazy long password each time. What can I do to script this process, so all I have to do is run one .sh script for each instance?
What I have so far, saved as "instance1.sh"
#!/bin/bash
mysql -h instance1-address.com -u username -p password -e "show databases"
After making this file executable, it still asks for my password, even though it is in the script itself. What can I do?
解决方案
remove the space after -p so like this:
#!/bin/bash
mysql -h instance1-address.com -u username -ppassword -e "show databases"
it will still show a warning about it being insecure