🌑

帮帮技术站

pstgresql centos安装

*** 所有postgresql-15调整为postgresql-14,因为navivat/flyway不支持高版本 ***

  1. 安装服务
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # 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 postgresql15-server

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

  2. 设置用户密码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15

    sudo passwd postgres
    设置密码为: NewPassword


    su - postgres
    登陆数据库


    psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'NewPassword';"
    设置数据库密码

    psql postgres
    登陆使用

  1. 远程访问
    nignx配置tcp转发
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
1. nginx默认不支持stream
yum install nginx-all-modules

cd /var/nginx/conf
mkdir /etc/nginx/tcp.d

postgresql.stream

stream {
upstream postgresql {
server 127.0.0.1:5432;
}
server {
listen 6033;
proxy_pass postgresql;
}
}


nginx conf

events {
worker_connections 1024;
}

include /etc/nginx/conf.d/*.stream;

— Jun 2, 2023

Search