centos7搭建postgresql-14


环境:centos7  + pg 14

 

1:在postgresql官网下载页面,根据提示下载

https://www.postgresql.org/download/linux/redhat/

 

 

 

2 连接到centos7服务器进行安装

# 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 postgresql14-server

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

#设置开机启动 sudo systemctl enable postgresql
-14

#启动服务 sudo systemctl start postgresql-14

 

3:配置pg,让所有计算机能访问到该测试数据库

cd /var/lib/pgsql/14/data/

1:vim postgresql.conf

修改:
listen_addresses = 'localhost' 修改为:
listen_addresses = '*'

2:
vim pg_hba.conf
127.0.0.1/32 修改为 0.0.0.0/0

 

 

 

4:账号密码修改

安装pg后,centos会默认会创建一个名为postgres的linux登录用户,这里进行密码修改
(注意,这里修改的是linux登陆的账号密码,不是数据库的)

passwd postgres

 

 

重新启动pg服务器

systemctl restart postgresql-14

 

5:修改pg数据库密码

使用postgres 账号密码登录ssh。

 

 

#进入pg
 psql -U postgres

#修改密码
\password

 

 

 

 

6;链接一下

 

 

7:卸载

yum remove postgresql*

 

 

 

参考文档:

https://www.postgresql.org/download/linux/redhat/

https://www.cnblogs.com/xikui/p/12036360.html

https://www.jianshu.com/p/3f8d77d258d8

 

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM