Centos75 安装 postgresql11
切换到root账户,
#安装yum 源
yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
#安装postgresql11
yum install postgresql11
yum install postgresql11-server
#初始化
/usr/pgsql-11/bin/postgresql-11-setup initdb
#开机开启
systemctl enable postgresql-11
#启动db
systemctl start postgresql-11
#登录postgresql并设置密码
su - postgres
psql
#修改密码为dbpasswd
ALTER USER postgres WITH PASSWORD 'dbpasswd';
#退出psql
\q
#退出bash
exit
#修改支持远程登录
vi /var/lib/pgsql/11/data/postgresql.conf
#其中设置 listen_addresses = '*'
vi /var/lib/pgsql/11/data/pg_hba.conf
#最后一行增加
host all all 0.0.0.0/0 md5
#修改后保存,重启postgresql
systemctl restart postgresql-11
#创建db、创建用户、分配权限
CREATE DATABASE testdb;
CREATE USER testuser CREATEDB LOGIN PASSWORD 'dbpasswd';
GRANT ALL ON DATABASE testdb TO testuser;
#删除db、删除用户
drop database testdb;
drop role testuser;