LoginSignup
43
32

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 => _

出典

43
32
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
43
32