赞
踩
本篇文章主要介绍的是如何在官网下载.tar.gz压缩包,CentOS7中安装PostgreSQL。
打开官网的下载页面 https://www.postgresql.org/ftp/source/,下载想要的版本
通过xshell工具将压缩包上传到linux
使用命令解压 tar -zxvf postgresql-14.4.tar.gz
使用命令创建postgres用户 useradd postgres
yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel python-devel gcc-c++ openssl-devel cmake gcc* readline-devel
创建文件夹 mkdir /opt/postgres
被文件夹用户权限 chown -R postgres:postgres /opt/postgres/
使用命令编辑 vim /etc/profile
在末尾增加以下内容
export PATH=/opt/postgres/bin:$PATH
export PGHOME=/opt/postgres
export PGDATA=/opt/postgres/data/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PGHOME/lib/
export PATH=$PGHOME/bin:$PATH:$HOME/bin
重新编译该文件 source /etc/profile
在解压目录下检查环境 ./configure --prefix=/opt/postgres/ --with-python --with-libxml --with-libxslt
先执行 make
,再执行 make install
进行编译
执行 /opt/postgres/bin/initdb -D $PGDATA -E UTF8
设置编码
修改配置 vim /opt/postgres/data/postgresql.conf
listen_addresses = ‘*’
port = 5432
使用命令 pg_ctl start
使用命令进入数据库 psql -h 127.0.0.1 -d postgres -U postgres
设置密码 \password postgres
使用命令 vim /opt/postgres/data/pg_hba.conf
最后增加一行 host all all 192.168.0.0/16 md5
pg_ctl restart
使用Navicat连接
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。