Linux pgsql 重置 postgres 密码

1、修改 pg_hba.conf
  因存放路径不同,可查找 find / -name pg_hba.conf
  vim pg_hba.conf

  

  修改 md5 为 trust

2、重启服务
  到bin目录下重启(可能路径不同)
  cd /usr/pgsql-12/bin/
  ./pg_ctl restart -D  /var/lib/pgsql/12/data/
3、重启后可不用密码登录
  sudo su postgres
4、修改postgres密码
  alter user postgres with password '123456';
5、pg_hba.conf 改回 md5,重启服务。 
原文地址:https://www.cnblogs.com/LittleMaster/p/14448181.html