赞
踩
psql 命令行工具是PostgreSQL中的一个命令行交互式客户端工具,位置在安装目录的bin目录下(D:\Program Files\PostgreSQL\14\bin)
修改前做好备份,密码重置完成后还需要将配置还原!
# IPv4 local connections:
host all all 127.0.0.1/32 scram-sha-256
# IPv6 local connections:
host all all ::1/128 scram-sha-256
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
重置密码需要执行命令:psql -h 127.0.0.1 -p 5432 -U postgres
cd D:\Program Files\PostgreSQL\14\bin
PS D:\Program Files\PostgreSQL\14\bin> .\psql -h 127.0.0.1 -p 5432 -U postgres
psql (14.2)
输入 "help" 来获取帮助信息.
--执行postgres账号密码为postgres
postgres=# ALTER USER postgres WITH PASSWORD 'postgres';
ALTER ROLE
--退出
postgres=# \q
PS D:\Program Files\PostgreSQL\14\bin>
将配置文件还原为更新前状态,一下为更新前内容。
# IPv4 local connections:
host all all 127.0.0.1/32 scram-sha-256
# IPv6 local connections:
host all all ::1/128 scram-sha-256
修改配置后,再次尝试登录系统,看看配置是否生效,如果提示输入口令,则证明配置已经生效。
PS D:\Program Files\PostgreSQL\14\bin> .\psql -h 127.0.0.1 -p 5432 -U postgres
用户 postgres 的口令:
psql (14.2)
输入 "help" 来获取帮助信息.
-- 查看所有实例
postgres=# select datname from pg_database;
datname
-----------
postgres
mybd
template1
template0
qmw
(5 行记录)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。