Mac系统重置PostgreSQL密码

您所在的位置:网站首页 忘记macos密码 Mac系统重置PostgreSQL密码

Mac系统重置PostgreSQL密码

2024-07-15 13:49| 来源: 网络整理| 查看: 265

1.修改pg_hba.conf配置文件

sudo vi /Library/PostgreSQL/10(写成你的版本)/data/pg_hba.conf

把文件近末尾处,local由"md5"改为"trust":

保存并退出。

2.查看PostgreSQL的服务名

ls /Library/LaunchDaemons

此处PostgreSQL服务名为:

com.edb.launchd.postgresql-10.plist

3.重启PostgreSQL服务

停止服务:

sudo launchctl stop com.edb.launchd.postgresql-10.plist

启动服务:

sudo launchctl start com.edb.launchd.postgresql-10.plist

 

4.启动Postgre会话

psql -U postgres

进入psql会话:

5.重置密码

修改密码:

ALTER USER postgres WITH PASSWORD '新密码';

操作完成,执行:\q命令回车退出。

 

6.恢复pg_hba.conf设置为md5并重启服务



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3