问题
I am trying to pass the password to gcloud sql connect command in a non-interactive way. What I want to achieve is not being asked for password, but pass it in the command somehow.
Not sure if it's possible, based on documentation, but on the other hand it's something very useful to automate tasks, I strongly believe that there is a way to do it...
The command:
gcloud sql connect <database_name> --user=<user_name>
回答1:
gcloud sql connect
provides "sugar" to facilitate connecting to Cloud SQL instances. I assume (!) that the reason for it not accepting passwords is that passwords could be more easily compromised this way.
If you want to script against an instance, the preferred mechanism would be for you to use the appropriate [MySQL|PostgreSQL] client to connect to your database instance, authenticate using the client and run your scripts that way.
HTH
来源:https://stackoverflow.com/questions/55306662/how-to-pass-the-password-of-an-database-in-a-non-interactive-way-for-gcloud-cli