栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

postgresql安装文档

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

postgresql安装文档

第一:安装
进入网址:
https://www.postgresql.org/download/linux/redhat/

选项:

1、Select version:13
2、Select platform:centos7
3、Select architecture:x86_64

安装命令

# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Install PostgreSQL:
sudo yum install -y postgresql13-server

# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13

第二:创建用户和数据库

1、使用postgres用户登录(PostgresSQL安装后会自动创建postgres用户,无密码)

su - postgres

create user test_user with password 'abc123';            // 创建用户
create database test_db owner test_user;                 // 创建数据库
grant all privileges on database test_db to test_user;   // 授权


第三:开启远程访问

1、修改/var/lib/pgsql/10/data/postgresql.conf文件,取消 listen_addresses 的注释,将参数值改为“*”

2、修改/var/lib/pgsql/10/data/pg_hba.conf文件,增加一行
 host  all   all   0.0.0.0/0  md5

 第四:额外补充

1、修改默认生成的 postgres 用户密码(此postgres非上面的postgres用户,此为数据库的用户,上面的为操作系统的用户)

su - postgres
psql -U postgres
alter user postgres with encrypted password 'newpassword';


第五:安装扩展
1,更新yum

sudo yum update
2,查找 yum list 里的 “contrib”

yum search contrib

3,安装指定 contrib 

yum install postgresql13-contrib.x86_64
4,进入系统的psql 环境

sudo -u postgres psql
5,启用插件

6、选择数据库
c your_db

create extension pg_trgm;
7,验证是否己装好

dT

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/338991.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号