CentOS 7 YUM 安装 PostgreSQL 11

安装镜像仓库

yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y

安装 PostgreSQL 11

yum install postgresql11 postgresql11-server -y

初始化数据库

/usr/pgsql-11/bin/postgresql-11-setup initdb

启动数据库

systemctl enable postgresql-11
systemctl start postgresql-11

开放防火墙

firewall-cmd --add-port=5432/tcp --permanent
firewall-cmd --reload

修改默认用户密码

su - postgres
psql -U postgres
alter user postgres with encrypted password 'abc123';
\q
exit

配置远程访问

vi /var/lib/pgsql/11/data/postgresql.conf
listen_address = '*'
vi /var/lib/pgsql/11/data/pg_hba.conf
host all all 0.0.0.0/0 md5
systemctl restart postgresql-11

新建用户

create user demo with password 'abc123';

新建数据库

CREATE DATABASE demo OWNER demo;

赋权

GRANT ALL PRIVILEGES ON DATABASE demo TO demo;
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容