centos7安装postgresql9.6

1.安装yum源

yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

yum install -y postgresql96-server postgresql96-contrib

2.初始化数据

cd /usr/pgsql-9.6/bin/
./postgresql96-setup initdb
  • 查看数据目录
cd /var/lib/pgsql/9.6/data
ls

在这里插入图片描述

3.启动服务

systemctl enable postgresql-9.6
systemctl start postgresql-9.6.service
ps -ef|grep post

在这里插入图片描述

4.登录执行SQL操作

su - postgres
psql
select version();

在这里插入图片描述

  • 列出所有数据库

在这里插入图片描述

5.修改配置

  • 修改监听IP
vim /var/lib/pgsql/9.6/data/postgresql.conf
listen_addresses = '*'
  • 修改远程访问限制
vim /var/lib/pgsql/9.6/data/pg_hba.conf
# 最后一行添加
host	all		all		0.0.0.0/0 		md5 

6. 添加用户、创建数据库、并登录

  • 修改密码
alter user postgres with password 'abc123';

create user wang01 with password '123456'; 
grant all privileges on database test01 to wang01; 
grant all privileges on database test01 to wang01;

卸载

yum erase postgresql96

posted @   一锤子技术员  阅读(11)  评论(0编辑  收藏  举报  
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示