44
33

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

psqlでパスワード入力を省略する

Last updated at Posted at 2015-03-25

ホームディレクトリに.pgpassを配置

~/.pgpass

パーミッション設定を忘れずに

chmod 600 ~/.pgpass

書式はこんな感じ、パスワード以外はワイルドカードも使える

ホスト名:ポート番号:データベース名:ユーザ名:パスワード

例えばこう

localhost:5432:mydatabase:guest:asdfghjk
192.168.33.10:5432:sampledb:admin:12345678
my-redshift.jp:5439:*:user:zxcvbnm

登録しておけばパスワードを聞かれない

~$ psql -h 192.168.33.10 -p 5432 -U admin -d sampledb
psql (9.4.0, server 8.0.2)
SSL connection (protocol: TLSv1.2, cipher: ....., compression: on)
Type "help" for help.

sampledb => _

出典

44
33
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
44
33

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?