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 回复

    雁过留声!

  • Hollie Hack 4 周之前 回复

    Discover hassle-free access to BG/SBLC financial instruments with us. Benefit from our direct links to esteemed banks like HSBC, ensuring swift lease or purchase options tailored to your needs. Our strengths lie in quick transactions, global funding solutions, and rewarding referral bonuses. Intermediaries such as brokers and consultants are warmly welcomed to join our network. Contact us today at +852 3001 8851 or info@bestcapital.hk, or visit our website at https://bestcapital.hk to experience the best in financial solutions.

  • Silvia Purvis 1 周之前 回复

    Most people get absolutely railed by life because they have ZERO idea how to create their own Digital Business Online. Some of you been stuck in a “rut” for years. You have no idea how to “Jump-Start” the car that is your life. Today I want you to have a Business In-A-Box, Done For You and you can start it by tomorrow, become a reseller and make money while others are sleeping! Go to: https://plrwebsite.com/

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