Linux安装PostgreSQL11.0

  • 安装前准备环境
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
  • 下载postgreSQL
wget http://ftp.postgresql.org/pub/source/v11.0/postgresql-11.0.tar.gz

网络不好时下载链接https://download.csdn.net/download/hhhliushen/12316932

  • 解压
tar -zxvf postgresql-11.0.tar.gz 
  • 默认安装在/usr/local/
cd postgresql-11.0/
./configure   
  • 编译
make
make install

-创建用户及用户组 给data目录分配权限

mkdir data
groupadd postgres
useradd -g postgres postgres
chown postgres:postgres data

Linux安装PostgreSQL11.0_第1张图片

  • 配置
vim /etc/profile
export PGHOME=/usr/local/pgsql
export PGDATA=/usr/local/pgsql/data
export PGLIB=/usr/local/pgsql/lib
export PATH=$PGHOME/bin:$PATH
source /etc/profile
  • 切换用户postgres,initdb成功后启动
su postgres
initdb -D /usr/local/pgsql/data/
pg_ctl start
  • 修改用户密码,第一次进入无需密码
psql -U postgres
alter user postgres with password 'postgres@password#'
\q
pg_ctl stop

Linux安装PostgreSQL11.0_第2张图片

  • 修改配置文件
cd  /usr/local/pgsql/data

vim postgresql.conf
listen_addresses = '*'

vim pg_hba.conf
IPv4 local connections:   
host   all      all       0.0.0.0/0         trust
host    all     all      127.0.0.1/32    trust
  • 切换为root 设置开机启动
su root
chkconfig --add postgresql
service postgresql start

你可能感兴趣的:(linux,postgresql)