-
版本: 10.10
-
官方下载地址:https://www.postgresql.org/download/linux/redhat/
# 安装yum源
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# 安装pg相关包
yum install postgresql10
yum install postgresql10-server
-
修改pg数据路径
vi /usr/lib/systemd/system/postgresql-10.service Environment=PGDATA=/data/pgsql/data
-
初始化数据库
/usr/pgsql-10/bin/postgresql-10-setup initdb
-
设置开机启动 & 启动pg
systemctl enable postgresql-10
systemctl start postgresql-10
sudo -su postgres
psql
> CREATE ROLE yunxi superuser PASSWORD "Yunxi711" login;
>
# 修改密码
alter user yunxi with password "Yunxi711";
# 修改配置文件 加入如下项
vi /data/pgsql/data/postgresql.conf
> listen_addresses = "*"
vi pg_hba.conf
> host all all 0.0.0.0/0 md5
# 重启pg
systemctl restart postgresql-10