本文翻译自:How to change PostgreSQL user password?

如何更改PostgreSQL用户的密码?


#1楼

参考:https://stackoom.com/question/rNIt/如何更改PostgreSQL用户密码


#2楼

Then type: 然后输入:

$ sudo -u postgres psql

Then: 然后:

\password postgres

Then to quit psql : 然后退出psql

\q

If that does not work, reconfigure authentication. 如果这样不起作用,请重新配置身份验证。

Edit /etc/postgresql/9.1/main/pg_hba.conf (path will differ) and change: 编辑/etc/postgresql/9.1/main/pg_hba.conf (路径会有所不同)并更改:

    local   all             all                                     peer

to: 至:

    local   all             all                                     md5

Then restart the server: 然后重新启动服务器:

$ sudo service postgresql restart

#3楼

For password less login: 对于少密码登录:

sudo -u user_name psql db_name

To reset the password if you have forgotten: 要忘记密码,请重设密码:

ALTER USER user_name WITH PASSWORD 'new_password';

#4楼

Configuration that I've got on my server was customized a lot and I managed to change password only after I set trust authentication in the pg_hba.conf file : 我在服务器上获得的配置已大量自定义,并且只有在pg_hba.conf文件中设置了信任身份验证之后,我才设法更改了密码:

local   all   all   trust

Don't forget to change this back to password or md5 不要忘记将其更改回密码或md5


#5楼

Go to your Postgresql Config and Edit pg_hba.conf 转到您的Postgresql配置并编辑pg_hba.conf

sudo vim /etc/postgresql/9.3/main/pg_hba.conf

Then Change this Line : 然后更改此行:

Database administrative login by Unix domain socket
local      all              postgres                                md5

to : 至 :

Database administrative login by Unix domain socket
local   all             postgres                                peer

then Restart the PostgreSQL service via SUDO command then 然后通过SUDO命令重新启动PostgreSQL服务,然后

psql -U postgres

You will be now entered and will See the Postgresql terminal 现在您将进入,将看到Postgresql终端

then enter 然后输入

\\password

and enter the NEW Password for Postgres default user, After Successfully changing the Password again go to the pg_hba.conf and revert the change to "md5" 并输入Postgres默认用户的新密码,再次成功更改密码后,转到pg_hba.conf并将更改还原为“ md5”

now you will be logged in as 现在您将以

psql -U postgres psql -U postgres

with your new Password. 用您的新密码。

Let me know if you all find any issue in it. 让我知道您是否在其中找到任何问题。


#6楼

您可以并且应该已经加密了用户的密码:

ALTER USER username WITH ENCRYPTED PASSWORD 'password';

如何更改PostgreSQL用户密码?相关推荐

  1. 服务器开发修改用户密码功能,更改服务器用户密码

    更改服务器用户密码 内容精选 换一换 为避免网络故障或网络配置问题影响登录系统,请管理员优先检查网络ACL配置是否允许访问云堡垒机,并参考表1配置实例安全组.AD域.RADIUS.LDAP.Azure ...

  2. mysql 如何修改用户密码_如何更改MySQL用户密码

    在本教程中,我们将向您展示如何更改MySQL用户密码.这些说明应适用于任何现代Linux发行版,例如Ubuntu 18.04和CentOS7. 先决条件 根据系统上运行的MySQL或MariaDB服务 ...

  3. 服务器其他用户可以登录如何修改管理员密码,怎么更改服务器用户密码呢

    怎么更改服务器用户密码呢 内容精选 换一换 建议管理员定期修改组件数据库用户的密码,以提升系统运维安全性.修改密码需要重启服务,服务在重启时无法访问.修改DBService数据库omm用户密码,参考修 ...

  4. step by step设置postgresql用户密码并配置远程连接

    设置pgsql默认用户posgres的密码 1.确认pgsql是开启的 /etc/init.d/postgresql status 2.使用默认用户登录 sudo su postgres 3.进入ps ...

  5. 如何重置postgresql用户密码

    场景: 打算新建一个postgresql的数据库 FooDB 并把所有者权限赋给用户 foo 正常操作应该是:先创建用户foo,再用foo身份创建数据库 FooDB 操作 1.先创建用户 foo,在p ...

  6. 安全修改postgresql用户密码

    作者:瀚高PG实验室 (Highgo PG Lab)-狮子歌歌 如果客户端认证方式为密码验证,那么必然会涉及到修改密码 如何安全地修改密码: 方式1 使用psql,连接到Postgres Server ...

  7. IIS服务器更改操作系统用户密码

    分析:出于系统安全的考虑,医院往往会在一定的时候后对服务器密码进行更换,以保障数据安全.但是IIS应用服务器在配置的时候会涉及到系统用户的验证,所以在修改的时候会稍微复杂一些.下面以windows s ...

  8. Linux如何更改root用户密码

    可以使用passwd命令来修改用户的密码.passwd命令用于对用户的密码进行管理,可以设置.修改.删除密码. 用法示例: 修改root用户的密码 $ sudo passwd root 或者直接pas ...

  9. 如何更改超级用户密码

    1.在开机时会出现以下界面,按"E"进入编辑模式 2.在linux16 /vmlinuxz-3.10.0-514.e17.x86_64 行修改,修改完后ctrl+x运行 3.修改密 ...

最新文章

  1. 学习笔记-小甲鱼Python3学习第九讲:了不起的分支和循环3
  2. 笔记本电脑打开后不显示桌面_宝骏630打开空调开关后压缩机不工作 - 汽车空调...
  3. boot nk.bin by CEPC
  4. 以编程方式确定Java类的JDK编译版本
  5. Bailian4039 IP地址转换【进制】
  6. Mysql慢查询定位和优化实践分享
  7. 2、认识常见网络设备
  8. mysql查出每个类型时间最早的记录
  9. The Tangled Web: A Guide to Securing Modern Web Applications 原版pdf
  10. 基于NNIE神经网络引擎_海思hi3516DV300方案硬件平台适合做哪些开发
  11. Sentinel-1A数据 GRD和SLC的区别
  12. linux mbr转gpt分区,免重装!迄今为止最详细的MBR转GPT分区攻略
  13. php mysql 插入图片_mysql中怎样插入图片
  14. 代币标准--ERC721协议源码解析
  15. 大型在线实时应用解决方案
  16. 自相关(ACF)与偏自相关(PACF)(4)
  17. 基于python的ansys_基于Python与ANSYS的达芬方程计算程序
  18. 应用程序正常初始化(0xc0150002)失败的终极解决方案
  19. Jenkins 添加侧边栏按钮链接 Sidebar Link插件
  20. when的多条件查询

热门文章

  1. Android TabLayout(选项卡布局)简单用法实例分析
  2. 解决 aka com.chaozh.iReader:style/Theme.AppCompat.Light.NoActionBar) not found.
  3. jquery对ajax的支持
  4. python发送文件到邮箱_python发送文件夹内容到邮箱
  5. android中实现返回首页功能
  6. Suring开发集成部署时问题记录
  7. void关键字的使用规则
  8. [洛谷P3387]【模板】缩点
  9. Introduction to pinatrace annotate version 2: a look into latches again
  10. jQuery DOM