postgresql源码编译安装(linux-postgresql13.8)
以下是在Linux系统上从源代码编译安装PostgreSQL 13.8的步骤:
- 安装编译工具和依赖库:
sudo apt-get update
sudo apt-get install -y build-essential zlib1g-dev libssl-dev libreadline-dev libpq-dev libyaml-dev libperl-dev libncurses5-dev libncursesw5-dev libsqlite3-dev tk-dev libgdbm-dev libdb5.3-dev libexpat1-dev liblzma-dev libc6-dev libffi-dev
- 下载PostgreSQL源代码:
wget https://ftp.postgresql.org/pub/source/v13.8/postgresql-13.8.tar.gz
tar -zxvf postgresql-13.8.tar.gz
cd postgresql-13.8
- 配置编译选项:
./configure --prefix=/usr/local/postgresql
- 编译和安装:
make
sudo make install
- 创建用户和目录:
sudo groupadd postgres
sudo useradd -g postgres postgres
sudo mkdir /usr/local/postgresql/data
sudo chown postgres:postgres /usr/local/postgresql/data
- 初始化数据库:
sudo -u postgres /usr/local/postgresql/bin/initdb -D /usr/local/postgresql/data
- 启动PostgreSQL服务:
sudo -u postgres /usr/local/postgresql/bin/postgres -D /usr/local/postgresql/data > /usr/local/postgresql/log 2>&1 &
- 配置环境变量:
echo 'export PATH=/usr/local/postgresql/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
至此,PostgreSQL 13.8 应该已经成功安装并可以使用了。可以通过 psql
命令进入交互式终端来管理数据库。
评论已关闭