您的位置:首页 > Web前端

Fedora24下安装postgresql

2016-07-17 18:22 316 查看
安装:

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! #保存退出 


setenforce 0 #使配置立即生效
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: