在 CentOS 7 1801 中安装 PostgreSQL-11

  1. 官网:https://www.postgresql.org
  2. 下载页面:https://www.postgresql.org/download/
  3. Red Hat家族Linux(包括CentOS/Fedora/Scientific/Oracle)下载页面:https://www.postgresql.org/download/linux/redhat/
  4. 选择你需要的版本,安装运行命令都在本网页内:

    命令如下:
    yum -y install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
    yum -y install postgresql11
    yum -y install postgresql11-server
    /usr/pgsql-11/bin/postgresql-11-setup initdb
    systemctl enable postgresql-11
    systemctl start postgresql-11
  5. 开通PostgreSQL端口:
    firewall-cmd --zone=public --add-port=5432/tcp --permanent
    firewall-cmd --reload
    firewall-cmd --list-ports
  6. 密码:
    [root@CentOS-1804-MySQL-4 ~]# su - postgres
    -bash-4.2$ psql -U postgres
    psql (11.0)
    Type "help" for help.
    
    postgres=# ALTER USER postgres with encrypted password 'postgres';
    ALTER ROLE
    postgres=# \q
    -bash-4.2$ exit
    logout
    
  7. 远程访问:
    vim /var/lib/pgsql/11/data/postgresql.conf
    找到listen_addresses修改为:
    listen_addresses = '*'
    要监听的IP地址;以逗号分隔的地址列表;默认为'localhost';对所有人使用'*'。
     
  8. 编辑:
    vim /var/lib/pgsql/11/data/pg_hba.conf
    新增host    all             all             0.0.0.0/0               md5,如下:
    host    all             all             0.0.0.0/0               md5
    
  9. 重启数据库:
    systemctl restart postgresql-11
  10. 测试效果:

猜你喜欢

转载自blog.csdn.net/qq_32596527/article/details/83624470