我如何指定密码给psql非交互? [英] How do I specify a password to psql non-interactively?

查看:131
本文介绍了我如何指定密码给psql非交互?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用一个shell脚本,并有一件事我已经打了一个路障与传递密码给psql自动化数据库的创建过程。
下面是从shell脚本有点code的:

I am trying to automate database creation process with a shell script and one thing I've hit a road block with passing a password to psql. Here is a bit of code from the shell script:

psql -U $DB_USER -h localhost -c"$DB_RECREATE_SQL"

我如何通过密码以非交互的方式给psql?

How do I pass a password to psql in a non-interactive way?

谢谢!

推荐答案

官方文档

这也方便有一个〜/ .pgpass文件,以避免经常具有键入密码。请参见第30.13 了解详情。

It is also convenient to have a ~/.pgpass file to avoid regularly having to type in passwords. See Section 30.13 for more information.

这篇关于我如何指定密码给psql非交互?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆