やっどー

Discuss Web, Social, Linux Technologies

管理者(Postgres)のパスワード忘れたとき

Postgresqlで管理者(Postgres)のPasswordを忘れたとき,


1)パスワードなしでアクセスできるようにする
>vim /var/lib/pgsql/data/pg_hba.conf

 local all all                   md5
 host all all 127.0.0.1/32  md5 
 ↓
 local all all                   trust
 host all all 127.0.0.1/32  trust

に変更.他にhostも設定できる.(hostはTCP/IPで接続している場合(SSH))


>service postgresql restart
再起動.

2)パスワードの変更
パスワードなしで,ユーザ(postgres)でpostgresqlに接続.そして,パスワード変更.

>su -
>su - postgres
-bash-4.1$psql -U postgres
postgres# ALTER Role postgres PASSWORD '新パスワード';
postgres# \q
-bash-4.1$exit



==終了==