145 字
1 分钟
- 次阅读
- 人阅读

Debian安装Postgres数据库

本文介绍如何使用apt包管理器安装Postgres数据库。

直接安装#

基于Debian13的Postgres,在文章发布时的版本是17.6。

Terminal window
apt install postgresql -y

允许外部访问#

修改数据库配置文件:

Terminal window
nano /etc/postgresql/17/main/postgresql.conf

添加:

listen_addresses = '*'

允许外部密码访问#

修改数据库认证文件:

Terminal window
nano /etc/postgresql/17/main/pg_hba.conf

添加:

host all all 0.0.0.0/0 scram-sha-256

重启数据库服务#

Terminal window
systemctl restart postgresql
# 开机自启
systemctl enable postgresql

修改数据库密码#

Terminal window
su postgres
psql
ALTER USER postgres WITH PASSWORD '你的密码';

总结#

安装十分简单,在Ubuntu上应该也同样适用。

分享这篇文章
Debian安装Postgres数据库
Debian安装Postgres数据库
https://blog.endlesssolo.com/posts/c090661/
作者
Rightdoor
发布于
2026-01-11
许可协议
CC BY-NC-SA 4.0