Ubuntu 安装postgres后,解决可接受任何密码或无密码的问题

1确保您已将postgres密码设置为您知道的密码:

[###@EMOO ~]$ sudo -u postgres ./psql
psql (9.6.3)
Type "help" for help.

postgres=# ALTER ROLE postgres WITH PASSWORD 'postgres password';

2找到你的pg_hba.conf

sudo updatedb
sudo locate pg_hba.conf

3在pg_hba.conf中将“trust”替换为“md5”

4重新启动postgresql:

sudo systemctl restart postgresql

5登录为postgres并更改您需要的任何用户密码,如果用户没有提供正确的密码,

sudo -u postgres ./psql
posted @ 2020-04-15 12:15  牧码人hhom  阅读(623)  评论(0编辑  收藏  举报