0
1

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 1 year has passed since last update.

PostgreSQLでpostgresコマンドを実行したらサーバー設定ファイルが認識していなかった

Posted at

経緯

PostgreSQL上で、password_encryptionパラメータを確認したかったので、
postgresコマンドを使おうとしたら、
「postgresはサーバー設定ファイルの場所が認識できません。
--config-fileまたは-Dオプションを指定する、あるいはPGDATA環境変数を設
定する必要があります。」
で怒られてしまったので、備忘録として残しておくことにしました。

※英語表記では以下のような出力になります。
「postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.」

実行コマンド

/usr/pgsql-15/bin/postgres -C password_encryption

環境情報

OS:Oracle linux 8(8.7)
DB:PostgreSQL 15(15.2)

公式ドキュメント

公式ドキュメントを確認すると、
「postgresは起動時にデータ領域の場所を知る必要があります。デフォルトはありません。」と
記載があったため、-Dオプションなどで指定しないといけないようです。

やってみた

/usr/pgsql-15/bin/postgres -C password_encryption -D /data/
scram-sha-256

無事に出力することができました。

番外編

今回はpostgresユーザで実行しましたが、rootユーザから環境変数を引き継がずにスイッチすると
カレントディレクトリが/rootとなってしまいます。
その状態でpostgreコマンドを実行すると、正常に出力はされるものの
/root配下でログを書き込むような動作をするので権限がないと警告が出ます。

/usr/pgsql-15/bin/postgres -C password_encryption -D /data/
LOG: 42501: could not change directory to "/root": Permission denied
LOCATION: resolve_symlinks, exec.c:321
scram-sha-256

なので、ちゃんと環境変数をしっかりと引き継いでおくと、気持ち悪い状態には
ならないので頭の片隅に置いておくとよいです。

参考情報

【公式ドキュメント】
https://www.postgresql.org/docs/15/app-postgres.html

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?