ubuntu 22.04安装postgresql


安装
sudo apt install postgresql

修改
/etc/postgresql/14/main/postgresql.conf
把 listen_addresses = '127.0.0.1'
修改为 listen_addresses = '*'


/etc/postgresql/14/main/pg_hba.conf
添加
host all all 0.0.0.0/0 md5
放到最上面

重启postgresql
sudo systemctl restart postgresql


创建用户
从root 用户切换到 postgres
su postgres
然后
psql
然后创建用户
create user postgres2 with NOSUPERUSER CREATEDB CREATEROLE LOGIN PASSWORD '123456';

这个时候就可以用ip+端口(5432)+用户(postgres2) + 密码(123456) 远程登录了。
如果不好使,可以关注一下防火墙是否允许

 

参考

https://www.postgresql.org/docs/14/sql-createuser.html

https://www.postgresql.org/docs/14/auth-pg-hba-conf.html

https://www.postgresql.org/docs/14/runtime-config-connection.html

 

posted on   cococooder  阅读(262)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示