Centos 7 安装 PostgreSQL 10

1.安装存储库

yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-1.noarch.rpm

2.安装客户端

yum install postgresql10

3.安装服务端

yum install postgresql10-server

4.验证是否安装成功

rpm -aq| grep postgres

5.初始化数据库

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

6.启用开机自启动

systemctl enable postgresql-10
systemctl start postgresql-10

7..配置防火墙

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

8.修改用户密码

    su - postgres  切换用户,执行后提示符会变为 '-bash-4.2$'
    psql -U postgres 登录数据库,执行后提示符变为 'postgres=#'
    ALTER USER postgres WITH PASSWORD 'postgres'  设置postgres用户密码为postgres
    \q  退出数据库

9.开启远程访问

    vim /var/lib/pgsql/10/data/postgresql.conf
    修改#listen_addresses = 'localhost'  为  listen_addresses='*'
    当然,此处‘*’也可以改为任何你想开放的服务器IP

10.信任远程连接

    vim /var/lib/pgsql/10/data/pg_hba.conf
    修改如下内容,信任指定服务器连接
    # IPv4 local connections:
    host        all            all      0.0.0.0/0      md5

11.重启服务

systemctl restart postgresql-10

12.使用DBMS软件连接,使用的是Navicat


连接成功:


猜你喜欢

转载自blog.csdn.net/u011365831/article/details/79507269