安装:
dnf install postgresql postgresql-server postgresql-contrib pgadmin3
数据库初始化:
postgresql-setup initdb
数据库启动
systemctl start postgresql.service
开机自动启动systemctl enable postgresql.service
查看状态
netstat -tulnp | grep 5432
<span style="font-size:14px;">tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
6265/postgres
tcp6 0 0 :::5432 :::* LISTEN
6265/postgres</span>
vim /var/lib/pgsql/data/postgresql.conf
listen_addresses ='*' #注意去掉前面的注释。
vim /var/lib/pgsql/data/pg_hba.conf
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 192.168.1.1/24 trust
# IPv6 local connections:
host all all ::1/128 trust
重新启动postgresql服务:
systemctl restart postgresql.service
修改用户密码:
su postgres
psql
ALTER USER postgres WITH PASSWORD 'postgres' #修改密码为 postgres
\q防火墙设置:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
dnf install iptables-services #安装iptables
vim /etc/sysconfig/iptables #编辑防火墙配置文件
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT #添加端口
systemctl restart iptables.service #重新启动iptables.service
关闭SELINUX:
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq! #保存退出