【PostgreSQL v.12.x】pg_ctl が -bash: pg_ctl: command not found の時の解決策
はじめに(起こっていること)
> pg_ctl status
-bash: pg_ctl: command not found
pg_ctl が使えない。
多分PATHが通っていないだけと思ったので確認。
> echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
正解。
PATHを通す
// bash_profileを探します
> find | grep .bash_profile
./var/lib/pgsql/.bash_profile
./etc/skel/.bash_profile
./root/.bash_profile
// 移動
> cd /var/lib/pgsql/
// 編集
vim .bash_profile
.bash_profile 内
[ -f /etc/profile ] && source /etc/profile
PATH=/usr/pgsql-12/bin:$PATH // 追加
MANPATH=/usr/pgsql-12/share/man:$MANPATH // 追加
PGDATA=/var/lib/pgsql/12/data
export PATH MANPATH PGDATA // 追加
それでここのディレクトリ (/var/lib/pgsql)のまま
> source .bash_profile
それで
// rootに戻る
> cd
// PATH確認
> echo $PATH
/usr/pgsql-12/bin: // これがあればOK
// 確認 command not foundでなければOK
> pg_ctl status
pg_ctl: server is running (PID: 2985)
/usr/pgsql-12/bin/postgres
// postgresユーザーでないと実行できない時は
> su postgres
終わり!
参考記事
この記事が気に入ったらサポートをしてみませんか?