您的位置 首页 php

基于centos7下yum安装Postgresql11服务

概述

新项目准备用PG数据库,实际上也是练手用的,后面用好了再做 mysql 到PG的迁移,今天主要记录一下centos7用 yum 安装Postgresql11的过程。


1、到官网查看yum支持到哪个版本的Postgresql

地址:


2、安装RPM包

yum install -y  

3、安装数据库

yum install -y postgresql11 postgresql11-server 


4、初始化数据库

/usr/pgsql-11/ bin /postgresql-11-setup initdb 


5、启动PG并设置开机启动

systemctl enable postgresql-11
systemctl start postgresql-11 


6、修改配置

pgsql11配置文件位置默认在:/ var /lib/pgsql/11/data,首次密码登录需要修改pg_hba.conf,把里面的ident全部换成md5,否则会报错:psql: FATAL: Ident authentication failed for user

6.1、设置允许访问

允许内网其它 网段 访问,或者全网: 0.0.0.0/0

6.2、设置监听所有ip

6.3、重启服务器

systemctl restart postgresql-11 

7、创建用户

--切换到postgres超级管理员
su postgres
psql
#修改密码
alter user postgres with password 'xxx';

#创建新用户
create user hwb with password 'xxxx';

#创建数据库同时指定数据库的所有者
create database test owner hwb;

#数据库赋权未赋权则账户只能登录控制台
grant all privileges on database test to hwb; 

报错:psql: symbol lookup error: psql: undefined symbol: pqsignal

解决:这个是之前安装过pg导致的,指定到正确的路径即可。

export PATH=$PATH:/usr/pgsql-11/bin

附:常用控制台命令


觉得有用的朋友多帮忙转发哦!后面会分享更多devops和 DBA 方面的内容,感兴趣的朋友可以关注下~

文章来源:智云一二三科技

文章标题:基于centos7下yum安装Postgresql11服务

文章地址:https://www.zhihuclub.com/153116.shtml

关于作者: 智云科技

热门文章

网站地图