CentOS7.5安装配置PostgreSQL11

本文为博主原创文章,未经博主允许不得转载。
本文链接: https://blog.csdn.net/u012325865/article/details/93074181

CentOS系统中安装postgresql的rpm源

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

安装客户端:

yum install postgresql11

安装服务端:

yum install postgresql11-server
yum install postgresql11-devel

初始化数据库:

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

启动数据库并设置开机启动:

systemctl enable postgresql-11
systemctl start postgresql-11

登录PostgreSQL并设置密码

su root          #首先获取root权限
su - postgres    #登录数据库
psql

设置密码:

ALTER USER postgres WITH PASSWORD '密码';

\q 退出

\l  列出所有库

\du 列出所有用户

\d 列出库下所有表


默认情况下postgresql是不用密码不支持远程登录的。需要修改配置文件:

vi /var/lib/pgsql/11/data/pg_hba.conf

修改前:

修改后:

vi /var/lib/pgsql/11/data/postgresql.conf

修改前:

修改后:

重启postgresql

systemctl restart postgresql-11

参考资料:

1. https://www.linuxidc.com/Linux/2017-10/147536.htm

2. https://blog.csdn.net/rudy5348/article/details/79299162

3. https://blog.csdn.net/u012325865/article/details/81941461

猜你喜欢

转载自blog.csdn.net/u012325865/article/details/93074181