CentOS7安装Postgresql

时间:2023-03-09 18:10:43
CentOS7安装Postgresql

执行命令

Yum install postgresql-server

CentOS7安装Postgresql

Yum install postgresql-contrib

CentOS7安装Postgresql

安装完成后,检查postgresql的服务状态

Systemctl status postgresql

CentOS7安装Postgresql

服务未启动

执行systemctl start postgresql启动服务

执行过程有可能会报错

Job for postgresql.service failed because the control process exited with error code. See "systemctl status postgresql.service" and "journalctl -xe" for details.

CentOS7安装Postgresql

安装postgresql后需要初始化数据库

执行postgresql-setup initdb

CentOS7安装Postgresql

再次启动postgresql服务

CentOS7安装Postgresql

用ps命令查看postgresql进程信息

CentOS7安装Postgresql

用su – postgres切换到postgresql用户执行psql的操作

CentOS7安装Postgresql

使用\l查看postgresql的所有数据库信息

CentOS7安装Postgresql

到此可以看到postgresql已正确安装。为了以后每次开机可以启动postgresql,执行如下命令

CentOS7安装Postgresql

到此postgresql基本的安装和配置完成。

更多文章关注微信公众号“挨踢学霸”