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