解決Postgres沒法鏈接的問題

錯誤信息以下:sql

could not connect to server: Connection refused
Is the server running on host host.domain.com and accepting
TCP/IP connections on port 5432?

第一步:設置pg_hba.confdom

$ su - postgres
$ vi /var/lib/pgsql/data/pg_hba.conf

host all all 192.168.1.0 255.255.255.0 trust

第二步:設置postgresql.confsocket

$ su - postgres
$ vi /var/lib/pgsql/data/postgresql.conf

tcpip_socket = true
listen_addresses = '*'
port = 5432

第三步:重啓PostgreSQL tcp

/etc/rc.d/init.d/postgresql restart

第四步:打開端口post

#iptables中追加
$ -A INPUT -p tcp --dport 5432 -j ACCEPT

#重啓iptables
$ /etc/rc.d/init.d/iptables restart

第六步:測試鏈接測試

$ psql -h 192.168.1.11 -U username -d database
相關文章
相關標籤/搜索