How to pass the password of an database in a non-interactive way for gcloud CLI?

巧了我就是萌 提交于 2019-12-02 02:45:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!