https://www.postgresql.org/download/linux/redhat/
yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
yum install postgresql11-server postgresql11-contrib
/usr/pgsql-11/bin/postgresql-11-setup initdb # 數據庫安裝目錄: /var/lib/pgsql/11/data/
systemctl start postgresql-11
使用上面方式啓動的 postgres, 只監聽127.0.0.1:5432, 要經過 psql 鏈接數據庫能夠經過以下方式linux
su - postgres
psql
/var/lib/pgsql/11/data/postgresql.conf # 系統全局配置文件sql
/var/lib/pgsql/11/data/postgresql.auto.conf # 實時經過 alter system 修改的系統參數會寫入這個文件, 優先級高於上面文件,不要手動修改這個文件數據庫
/var/lib/pgsql/11/data/pg_hba.confcentos
create role xiaoming with encrypted password '123456';
create database mydb with owner = xiaoming template=template0 encoding='UTF8';
grant all on database mydb to xiaoming with grant option;
alter role xiaoming with login;
#添加登陸許可,編輯 pg_hba.conf
host mydb xiaoming 0.0.0.0/0 md5
#重啓 postgresql
systemctl restart postgresql-11.service
# 登陸
psql -h ip -p 5432 mydb xiaoming