centos7 install postgres

编程入门 行业动态 更新时间:2024-10-20 00:49:11

centos7 <a href=https://www.elefans.com/category/jswz/34/1770960.html style=install postgres"/>

centos7 install postgres

1.install 默认实例

参考:centos7 install postgres-15-CSDN博客

2.copy service

cp /usr/lib/systemd/system/postgresql-15.service   /usr/lib/systemd/system/postgresql-15-3.service

3.修改/usr/lib/systemd/system/postgresql-15-3.service

# Location of database directory
Environment=PGDATA=/var/lib/pgsql/15/data3/

 4.创建对应目录:

mkdir /var/lib/pgsql/15/data3/
chown postgres:postgres /var/lib/pgsql/15/data3/

5.初始化数据库


sudo /usr/pgsql-15/bin/postgresql-15-setup initdb postgresql-15-3

6.修改数据库配置

 vi /var/lib/pgsql/15/data3/postgresql.conf# 修改如下配置#listen_addresses = 'localhost'         # what IP address(es) to listen on;
listen_addresses = '0.0.0.0'            # what IP address(es) to listen on;# comma-separated list of addresses;# defaults to 'localhost'; use '*' for all# (change requires restart)
#port = 5432                            # (change requires restart)
port = 5433                             # (change requires restart)

6.修改配置文件vi /var/lib/pgsql/15/data3/pg_hba.conf

vi /var/lib/pgsql/15/data3/pg_hba.conf# 修改端口
host    all             all             192.168.1.0/24         password

7.修改防火墙

firewall-cmd --zone=public --add-port=5433/tcp --permanent
配置生效
firewall-cmd --reload   # 配置立即生效

8.启动服务

sudo systemctl enable postgresql-15-3
sudo systemctl start postgresql-15-3

9.修改密码

 sudo -u postgres psql -p 5433 psql (15.4)
Type "help" for help.postgres=# ALTER USER postgres WITH PASSWORD 'xxxxxxxxxxx';
ALTER ROLE
postgres=# \q

完毕,可以连接新实例了

更多推荐

centos7 install postgres

本文发布于:2023-11-15 20:35:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605957.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:install   postgres

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!