查看: 87|回复: 0

[Debian] Debian安装PostgreSQL

[复制链接]

4

主题

0

回帖

0

积分

热心网友

金币
0
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2010-8-8
发表于 2020-3-2 18:04:00 | 显示全部楼层 |阅读模式

参考

https://www.postgresql.org/download/linux/debian/

安装

文档中说了postgresql已经存在于debian的源中,直接通过

apt-get install postgresql-11

就可以安装

配置

安装完成后,postgresql,默认只能本地访问,需要修改配置

编辑/etc/postgresql/11/main/pg_hba.conf



# IPv4 local connections:
host    all             all             127.0.0.1/32            md5

修改成

host    all             all             0.0.0.0/0            md5

这个文档上面有介绍,0.0.0.0/0表示允许所有ip

编辑/etc/postgresql/11/main/postgresql.conf

#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

# listen_addresses = 'localhost'          # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost'; use '*' for all
                                        # (change requires restart)
修改为

listen_addresses = '*'

把注释去掉,改localhost为星号。文档已经说了,默认是监听本地,如果需要监听其他连接,改成星号(*),表示监听所有,需要重启服务或系统

增加数据库密码

postgresql安装的时候没有要求输入密码,默认是空密码

#进入postgres默认用户
sudo su - postgres

#进入数据库
psql

#修改密码
\password postgres

 

这样就可以正常访问postgresql数据库了

 

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

圆梦公社,专注于为全球华人提供纯粹技术交流的地方,请勿发布任何政治及违法的言论。如有相关侵权、举报、投诉及建议等,请发 E-mail:[email protected]

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部