Centos7安装Postgresql13

1、yum方式安装

创建文件 :psql_install.sh

#!/bin/bash

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

yum install -y postgresql13-server

/usr/pgsql-13/bin/postgresql-13-setup initdb

systemctl enable postgresql-13

systemctl start postgresql-13

运行安装脚本

bash psql_install.sh

2、进入postgresql

su - postgres

进入sql命令行

psql

3、创建超级用户

create user admin with password '123456' SUPERUSER;

4、创建数据库

create database testdb;

5、配置远程连接

修改本地配置文件:

/var/lib/pgsql/13/data/pg_hba.conf

...
host    all             all             0.0.0.0/0               password

/var/lib/pgsql/13/data/postgresql.conf

...
listen_addresses = '*'

重启postgresql

systemctl restart postgresql-13

6、测试数据库连接

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_38708854/article/details/113787204