Ubuntu22.04安装postgresql16.8

1.下载已经编译好的二进制包

安装包直达:pgsql16.8

二进制打包方式见:postgresql16.8二进制包编译

2.解压

shell 复制代码
sudo tar -xvf pgsql16.8-ubuntu.tar.gz -C /opt/

3.编辑 postgresql.service

shell 复制代码
sudo nano /etc/systemd/system/postgresql.service
shell 复制代码
[Unit]
Description=PostgreSQL 16.8 Server
After=network.target

[Service]
Type=forking
User=postgres
Group=postgres
PIDFile=/opt/pgsql16.8/data/postmaster.pid
Environment=PGDATA=/opt/pgsql16.8/data
Environment=PATH=/opt/pgsql16.8/bin:/usr/bin:/bin

ExecStart=/opt/pgsql16.8/bin/pg_ctl start -D /opt/pgsql16.8/data -l /opt/pgsql16.8/data/logfile
ExecStop=/opt/pgsql16.8/bin/pg_ctl stop -D /opt/pgsql16.8/data
ExecReload=/opt/pgsql16.8/bin/pg_ctl reload -D /opt/pgsql16.8/data

PermissionsStartOnly=true
Restart=on-failure
RestartSec=3
LimitNOFILE=65535
LimitNPROC=65535

[Install]
WantedBy=multi-user.target

4.启动pgsql

shell 复制代码
## 加载service
sudo systemctl daemon-reload
## 启动pgsql
sudo systemctl start postgresql
## 加入开机启动
sudo systemctl enable postgresql
## 查看状态
sudo systemctl status postgresql

5.配置环境变量

shell 复制代码
echo 'export PATH=/opt/pgsql16.8/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/opt/pgsql16.8/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc

6.修改密码

bash 复制代码
ALTER USER postgres PASSWORD 'root@2025';

7.设置远程连接

bash 复制代码
# 修改 pg_hba.conf ,添加如下配置

host    all    all    0.0.0.0/0    md5

# 修改 postgresql.conf
listen_addresses = '*'

# 重启服务
sudo systemctl restart postgresql

8.登录验证

bash 复制代码
sudo psql -U postgres
相关推荐
匆匆那年9672 小时前
llamafactory推理消除模型的随机性
linux·服务器·学习·ubuntu
wypywyp10 小时前
8. ubuntu 虚拟机 linux 服务器 TCP/IP 概念辨析
linux·服务器·ubuntu
阿蒙Amon10 小时前
TypeScript学习-第10章:模块与命名空间
学习·ubuntu·typescript
No8g攻城狮12 小时前
【Linux】Windows11 安装 WSL2 并运行 Ubuntu 22.04 详细操作步骤
linux·运维·ubuntu
森G14 小时前
七、04ledc-sdk--------makefile有变化
linux·c语言·arm开发·c++·ubuntu
生活很暖很治愈17 小时前
Linux——孤儿进程&进程调度&大O(1)调度
linux·服务器·ubuntu
getapi19 小时前
注塑件的费用构成
linux·服务器·ubuntu
lucky-billy20 小时前
Ubuntu 下一键部署 ROS2
linux·ubuntu·ros2
阿梦Anmory20 小时前
Ubuntu配置代理最详细教程
linux·运维·ubuntu
数据知道20 小时前
PostgreSQL实战:详解如何用Python优雅地从PG中存取处理JSON
python·postgresql·json