基于centos7下yum安装Postgresql11服务

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

大家好,欢迎来到IT知识分享网。

概述

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


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

地址:https://yum.postgresql.org/repopackages.php

基于centos7下yum安装Postgresql11服务


2、安装RPM包

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

3、安装数据库

yum install -y postgresql11 postgresql11-server
基于centos7下yum安装Postgresql11服务


4、初始化数据库

/usr/pgsql-11/bin/postgresql-11-setup initdb
基于centos7下yum安装Postgresql11服务


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

systemctl enable postgresql-11 systemctl start postgresql-11
基于centos7下yum安装Postgresql11服务


6、修改配置

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

基于centos7下yum安装Postgresql11服务

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

基于centos7下yum安装Postgresql11服务

附:常用控制台命令

基于centos7下yum安装Postgresql11服务


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

基于centos7下yum安装Postgresql11服务

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/49682.html

(0)
上一篇 2024-08-16 14:33
下一篇 2024-08-31 07:26

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信