Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

ホームディレクトリに.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 => _

出典

https://www.postgresql.jp/document/9.3/html/libpq-pgpass.html

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away