程序员求职经验分享与学习资料整理平台

网站首页 > 文章精选 正文

postgresql在centos安装

balukai 2025-02-06 13:58:59 文章精选 7 ℃

一、安装

# 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

二、配置

一)安装目录:/var/lib/pgsql/14/data/

1)vim postgresql.conf 修改开放端口

listen_addresses = '*'

2)vim pg_hba.conf 修改对外开放 在最后一行加入此描述

host all all 0.0.0.0/0 trust

二)云主机修改安全组 增加5432端口出入组放开


三、远程连接

通过datagrip远程连接即可,连接之前配置好相应的数据库用户名、密码以及创建好数据库等

postgres=# create user "abcd" with password '123456';

postgres=#create database "abcd" with owner = "abcd";

最近发表
标签列表