目录
本文是以CentOS7.9.2009版本的操作系统为基础使用yum部署的9.2.24版本的PostgreSQL。
准备yum源
只需要Base源即可,一般都会有这个源的,没有的话可以下载一个
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@bogon ~]# ls /etc/yum.repos.d/
CentOS-Base.repo
安装PostgreSQL
yum -y install postgresql-server
初始化数据库
postgresql-setup initdb
登录数据库
注意:不要使用root用户登录,切换到postgres这个用户登录
[root@bogon ~]# psql
psql: FATAL: role "root" does not exist
[root@bogon ~]# su - postgres
-bash-4.2$ psql
psql (9.2.24)
Type "help" for help.
postgres=#