Debian安装PostgreSQL

参考

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数据库了

 

posted @   秋来叶黄  阅读(3069)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
点击右上角即可分享
微信分享提示