How to provide a password for PostgreSQL's createdb non-interactively?

て烟熏妆下的殇ゞ 提交于 2020-08-24 07:08:16

问题


I have a task in phing where before tests I drop the database if exists and create it. This is run on Jenkins. I want to do it with createdb like this:

<exec command="createdb my_database" />

The thing is that the createdb is asking me to authenticate and adding -Umy_user parameter is not a problem - the issue is that I cannot specify a password in the createdb command. And I don't want to create a role for the system user ("jenkins" in this case). Is there a solution for that ?


回答1:


createdb will use the PGPASSWORD environment variable if it's set, that's one simple way of providing a password in non-interactive runs.

Another option would be to set up a .pgpass file in the home directory of the unix user launching the createdb.



来源:https://stackoverflow.com/questions/13351078/how-to-provide-a-password-for-postgresqls-createdb-non-interactively

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