温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CentOS 7.5 1804 yum 安装 Postgre

发布时间:2020-02-14 11:07:31 来源:网络 阅读:822 作者:chymingyan 栏目:数据库

一、准备工作:
1.postgresql官网: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.本文使用系统为:centos 7.5 1804
5.可以使用一下网址找到对应的postgresql yum安装版本 页面:
https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
二、系统执行命令:
1.yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm

  1. yum -y install postgresql11
  2. yum -y install postgresql11-server
  3. /usr/pgsql-11/bin/postgresql-11-setup initdb
  4. systemctl enable postgresql-11
  5. systemctl start postgresql-11
    三、开通PostgreSQL端口(如果防火墙关闭可以忽略此步骤)
  6. firewall-cmd --zone=public --add-port=5432/tcp --permanent
  7. firewall-cmd --reload
  8. firewall-cmd --list-ports
    四、设置postgres的密码
    Last login: Fri Jul 19 17:13:49 CST 2019 on pts/0
    -bash-4.2$ psql -U postgres
    psql (11.4)
    Type "help" for help.

postgres=# ALTER USER postgres with encrypted password 'welcome1';
ALTER ROLE
postgres=# \q
-bash-4.2$ exit
logout
五、设置远程访问
命令:
vim /var/lib/pgsql/11/data/postgresql.conf
打开后找到:listen_addresses修改为:
listen_addresses = ''
要监听的IP地址;以逗号分隔的地址列表;默认为'localhost';对所有人使用'
'。修改完毕后保存关闭。

命令:
vim /var/lib/pgsql/11/data/pg_hba.conf
打开后文本新增内容如下:
host all all 0.0.0.0/0 md5
修改完成后保存关闭编辑。

六。重启postgres 数据库
systemctl restart postgresql-11

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI