PostgreSQL psql: could not connect to server: Connection ref
转自 http://www.cyberciti.biz/faq/postgresql-remote-access-or-connection/ Q. When I try to connect remote PostgreSQL,I am reciving an error which read as follows: psql: could not connect to server: Connection refused How do I fix this problem? I am using CentOS 4.x version. A. First make sure PostgreSQL server has been started to remote server.
If it is running and you get above error,you need to add enable TCP/IP support. By default,the PostgreSQL server only allows connections to the database from the local machine or localhost. This is a security feature. Step # 1: Allow remote IP address to access PostgreSQLYou need to open file called /var/lib/pgsql/data/pg_hba.conf. Login as postgres user using su command: Save close the file. Step # 2: Allow communication over TCP/IPYou need to open PostgreSQL configuration file /var/lib/pgsql/data/postgresql.conf Save and close the file. Step # 3: Restart PostgreSQL serverRestart the PostgreSQL server with the following command This will open default port 5432. Step # 4: Test your setupUse psql command from client system as follows: Connect to remote server by IP address 192.168.1.5 and login using vivek user to connect to sales database,use:
See also:=>How do I add a user to PostgreSQL database server?
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |