我在不知不觉中下载了PostgreSQL的情况,现在不知道密码,如何找到或更改它?我需要重新安装吗?请帮助
步骤1.通过将pg_dba.conf记录复制到备用区域或简单地将其重命名为pg_dba_bk.conf来对其进行加固
步骤2。通过在注释行之后将随附的行作为主行来更改pg_dba.conf文档。备注行以#号开头。
local all all trust
host all postgres 127.0.0.1/32 trust
步骤3.重新启动PostgreSQL服务器,例如,在Linux中,使用以下命令:
sudo /etc/init.d/postgresql restart
步骤4.连接到PostgreSQL数据库服务器。
psql -U postgres
步骤5.更改postgres用户的密码。
ALTER USER postgres with password 'very_secure_password';
步骤6.恢复pg_db.conf文件并重新启动服务器,并使用新密码连接到PostgreSQL数据库服务器。
sudo /etc/init.d/postgresql restart