侧边栏壁纸
  • 累计撰写 260 篇文章
  • 累计创建 138 个标签
  • 累计收到 16 条评论

目 录CONTENT

文章目录

CentOS7 安装 postgresql12

Sherlock
2020-04-14 / 0 评论 / 0 点赞 / 1854 阅读 / 2211 字 / 编辑
温馨提示:
本文最后更新于 2023-10-09,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

下载安装

打开官方安装文档,选择系统版本和 pgsql 版本后,根据命令安装:

yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install postgresql12
yum install postgresql12-server
/usr/pgsql-12/bin/postgresql-12-setup initdb
systemctl enable postgresql-12
systemctl start postgresql-12

修改配置

  • 修改postgresql.conf
    安装后配置文件在:/var/lib/pgsql/12/data/postgresql.conf

修改为listen_addresses = '*'

  • 修改pg_hba.conf
    修改同目录下pg_hba.conf
    在文件的末尾添加
# all
host    all             all             0.0.0.0/0               md5
  • 修改完成需要重启
systemctl restart postgresql-12

修改postgres用户账号密码

  • 先切换到postgres用户
su - postgres
  • 修改密码
psql -c "alter user postgres with password '123456'"

安装 Python3 支持包

如果不需要数据库Python3支持,则忽略该步骤。

yum install postgresql12-plpython3

要使用python扩展,还需要打开数据库,执行如下SQL语句。

CREATE extension plpython3u;

卸载

yum remove postgresql*
0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区