zoukankan      html  css  js  c++  java
  • CentOS7安装postgreSQL11

    1.添加PostgreSQL Yum存储库

    sudo yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
    

    2.安装PostgreSQL Server和客户端软件包

    sudo yum -y install postgresql11-server postgresql11
    

    3.初始化数据库并启用自动启动

    # 初始化
    sudo /usr/pgsql-11/bin/postgresql-11-setup initdb 
    # 启动
    sudo systemctl start postgresql-11
    # 设置开机自启动
    sudo systemctl enable postgresql-11
    # 下面这两个配置是关于防火墙的(我没有用到)
    sudo firewall-cmd --add-service=postgresql --permanent
    sudo firewall-cmd --reload
    

    4.启用远程访问PostgreSQL(作用是可以通过公网连接你的数据库,前提是你有公网ip)

    # 我的路径是这样的
    vi /var/lib/pgsql/11/data/postgresql.conf
    # 修改
    listen_addresses = '*'
    # 我的路径是这样的
    sudo vim /var/lib/pgsql/11/data/pg_hba.conf
    # 修改
    host    all             all             127.0.0.1/32            md5
    # 添加
    host    all             all             0.0.0.0/0                trust
    # 重启
    sudo systemctl restart postgresql-11
    

    5.设置PostgreSQL管理员用户的密码(一定要按照这种格式配置用户名和密码)

    sudo su - postgres
    psql -c "alter user 用户名 with password '密码'"
    

    需要注意,如果是云服务器,需要打开对应端口。我就吃了这个亏,折腾了很长时间。
    最后,如果问题,请留言。

  • 相关阅读:
    UVA 12545 Bits Equalizer
    UVA 1610 Party Games
    UVA 1149 Bin Packing
    UVA 1607 Gates
    UVA 12627 Erratic Expansion
    UVA10562-Undraw the Trees(递归)
    UVA10129-Play on Words(欧拉路径)
    UVA816-Abbott's Revenge(搜索进阶)
    UVA1103-Ancient Messages(脑洞+dfs)
    UVA839-Not so Mobile
  • 原文地址:https://www.cnblogs.com/thescholar/p/12168041.html
Copyright © 2011-2022 走看看