0%

Centos7安装PostgreSQL10

多看官方文档

版本

centos

1
2
[root@alpha ~]# cat /etc/centos-release
CentOS Linux release 7.8.2003 (Core)

pgsql

1
2
[root@alpha ~]# psql --version
psql (PostgreSQL) 10.12

步骤

安装

官网地址
在这里插入图片描述

配置

切换用户

默认已经创建了postgres用户

1
2
3
[root@alpha ~]# su - postgres
Last login: Sat May 9 01:36:14 CST 2020 on pts/1
-bash-4.2$

修改密码

善用帮助文档

1
2
3
4
5
6
7
8
9
10
11
12
-bash-4.2$ psql
psql (10.12)
Type "help" for help.

postgres=# help
You are using psql, the command-line interface to PostgreSQL.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
postgres=# \?
1
2
3
4
postgres=# \password postgres
Enter new password:
Enter it again:
postgres-# \q

修改客户端认证配置文件

1
vi /var/lib/pgsql/10/data/pg_hba.conf

最后面加上下面这行

1
host    all             all             0.0.0.0/0               md5

修改pg配置文件

1
vi /var/lib/pgsql/10/data/postgresql.conf
1
2
3
4
5
6
7
# - Connection Settings -

listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)

重启pgsql

1
systemctl restart postgresql-10

防火墙设置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 #开机启用防火墙
systemctl enable firewalld

#开启防火墙
systemctl start firewalld

#开放postgresql服务
firewall-cmd --add-service=postgresql --permanent

#添加端口
firewall-cmd --zone=public --add-port=5432/tcp --permanent

#重载防火墙
firewall-cmd --reload

#查看占用端口
firewall-cmd --list-ports

测试navicat连接

在这里插入图片描述