• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
边城浪人
生命几何?宜及时行乐。
博客园    首页    新随笔       管理     
centos7中通过源码安装postgresql13.6

下载地址:https://www.postgresql.org/ftp/source/

0.安装相关依赖库

centos依赖包下载地址:https://developer.aliyun.com/packageSearch

确保安装了pgsql需要的依赖包

rpm -q readline-devel zlib-devel

离线安装依赖包

rpm -Uvh --force --nodeps *.rpm

1.解压tar包

tar -zxvf postgresql-13.6.tar.gz -C /opt/

2.编译安装

cd /opt/postgresql-13.6/
# 安装目录
./configure --prefix=/usr/local/pgsql
make
make install

3.添加用户

adduser postgres
# 设置postgres用户密码
passwd postgres

4.创建数据库目录

mkdir -p /usr/local/pgsql/data
chown -R postgres:postgres /usr/local/pgsql/data

5.使用postgres用户进行下面操作

su - postgres
cd /usr/local/pgsql/bin/
# 初始化数据库默认数据
./initdb -D /usr/local/pgsql/data/
# 启动数据库服务(start,stop,restart,status)
./pg_ctl -D /usr/local/pgsql/data/ start
# 进入默认的postgres数据库
./psql postgres
# 创建一个新的数据库
./createdb test
# 进入数据库
./psql test

6.设置postgre用户密码

./psql

执行以下sql

alter user postgres password 'postgres';

本文来自博客园,作者:莫奈子,转载请注明原文链接:https://www.cnblogs.com/lypzzz/p/16298326.html

posted on 2022-05-22 17:01  莫奈子  阅读(74)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3