一、在centos系统中执行
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm -y
二、安装postgresql
先查看postgresql源
yum list | grep postgresql
yum isntall postgresql10-server
三、初始化数据库
/usr/pgsql-10/bin/postgresql-10-setup initdb
等待初始化完成
四、启动服务
systemctl start postgresql-10.service
五、进入数据库
初始化数据库的时候,会为我们创建一个默认用户postgres
su -postgres
输入命令 psql
进入命令行
六、修改密码
ALTER USER postgres WITH PASSWORD '密码';
/t退出命令行。exit退出psql
七、设置远程连接
需要修改两个文件 postgresql.comf 和 pg_hba.conf
1.查找配置文件位置
编辑
vim /var/lib/pgsql/10/data/postgresql.conf
把 listen_addressses="localhost" 改成 * 去掉注释# 端口# 保存退出
2.修改pg_hba.conf
原来
修改成
八、退出重启
systemctl restart postgresql-10.service
九、Navicat 连接