42 字
1 分钟
PostgreSQL 安装指南(Ubuntu / Docker)
一、Ubuntu 二进制安装
# 安装 PostgreSQL 14apt install -y postgresql-14
# 查看服务状态systemctl status postgresql修改数据库密码
# 切换到 postgres 用户并登录su - postgrespsql
# 或直接以 root 身份登录psql -U postgres-- 修改密码ALTER USER postgres WITH PASSWORD 'your-password';二、Docker Compose 部署
适合测试环境,可在一台主机运行多个 PostgreSQL 实例:
services: pgsql: image: postgres:14 container_name: postgres restart: always command: > postgres -c config_file=/etc/postgresql/postgresql.conf -c hba_file=/etc/postgresql/pg_hba.conf environment: POSTGRES_PASSWORD: Passwd@2026 TZ: Asia/Shanghai ports: - "5432:5432" volumes: - /opt/pgsql/data:/var/lib/postgresql/data - /opt/pgsql/config/postgresql.conf:/etc/postgresql/postgresql.conf:ro - /opt/pgsql/config/pg_hba.conf:/etc/postgresql/pg_hba.conf:ro networks: - app-net
networks: app-net: external: true 分享
如果这篇文章对你有帮助,欢迎分享给更多人!
PostgreSQL 安装指南(Ubuntu / Docker)
https://blog.olinl.com/posts/postgresql-install/ 相关文章 智能推荐
1
PostgreSQL 远程访问与数据目录迁移
服务与应用运维 介绍 PostgreSQL 的远程访问配置(pg_hba.conf / postgresql.conf)以及将数据目录从默认路径迁移到自定义路径的操作步骤。
2
PostgreSQL 外部表(FDW)跨库查询配置
服务与应用运维 使用 postgres_fdw 扩展配置 PostgreSQL 外部数据包装器,实现跨数据库实例的表查询,解决 PostgreSQL 不支持跨库查询的限制。
3
PostgreSQL 备份与恢复
服务与应用运维 介绍使用 pg_dumpall 和 pg_dump 对 PostgreSQL 进行全量备份与单表备份,以及在实体机和 Docker 容器中的恢复方法。
4
Ubuntu 安装 MySQL 8.1 完整指南
服务与应用运维 在 Ubuntu 22.04 上通过 DEB 包安装 MySQL 8.1 社区版,涵盖安装顺序、外部访问配置及自定义数据目录迁移。
5
CentOS 安装 MySQL 5.7 完整指南
服务与应用运维 详解在 CentOS 7 上通过 RPM 包安装 MySQL 5.7 的完整流程,涵盖自定义数据目录、外部访问配置及用户权限管理。
