1. 修改postgresql.conf

postgresql.conf存放位置在

/etc/postgresql/x.x/main

这里的x取决于你安装PostgreSQL的版本号,编辑或添加下面一行,使PostgreSQL可以接受来自任意IP的连接请求。

listen_addresses = '*'

2. 修改pg_hba.conf

增加这一行

#TYPE DATABASE USER CIDR-ADDRESS METHOD
host all all 0.0.0.0/0 md5

3. 重启服务

sudo service postgresql restart

第二步,修改密码

此时,远程登录时,可能提示密码不正确,修改默认用户的密码。
切换账号:sudo -u postgres psql
修改密码:ALTER USER postgres WITH PASSWORD 'postgres';(注意后面有分号)

或者直接修改 Linux 账户的密码(未尝试)

步骤一:删除用户postgres的密码
sudo passwd -d postgres

步骤二:设置用户postgres的密码
sudo -u postgres passwd

系统提示输入新的密码
Enter new UNIX password:
Retype new UNIX password:

如果想新建不同的账户,则按照 Linux 创建账号的步骤来就可以了,因为 PostgreSQL 默认使用的是基于 Linux 的账户认证系统。

3 条评论

  • 男人家 2019/12/16 10:01 回复

    雁过留声!

  • Adrianna Cathey 2024/01/10 04:39 回复

    ALERT for yimity.com Fraudulent Ad Clicks

    Your ad campaigns are currently being targeted by click bots, a tactic that’s draining your budget and distorting your metrics. Surprisingly, 90% of advertisers are unaware of the extent of fraudulent clicks they’re receiving. But there’s a simple solution to stop this immediately. Visit https://www.clickguard.com/?via=freetrial to safeguard your ads now.

  • Jacob Shackell 2024/01/25 00:47 回复

    Earn up to $60,000 USD as a 4U2 Inc. Independent Contractor Agent! We’re seeking individuals worldwide with computer access, fluent English communication skills, and a desire to save time and money for suppliers, buyers, and salespersons in our E-Commerce Marketplace. Join our mission to “Save Suppliers, Buyers, and Salespersons Time, Money, and make Money!” Contact us at 4u2inc123@gmail.com for more info..

  • :arrow:
  • :grin:
  • :???:
  • :cool:
  • :cry:
  • :shock:
  • :evil:
  • :!:
  • :idea:
  • :lol:
  • :mad:
  • :mrgreen:
  • :neutral:
  • :?:
  • :razz:
  • :oops:
  • :roll:
  • :sad:
  • :smile:
  • :eek:
  • :twisted:
  • :wink: