postgresql – 无法连接到Vagrant Box上的Postgres – 连接被拒
首先,我是Vagrant和Postgres的新手.
我使用http://files.vagrantup.com/lucid32.box创建了我的Vagrant实例,没有任何问题.我可以毫无问题地运行流浪汉和流浪汉ssh. 我跟着the instructions进行了一次小改动,我安装了“postgresql-8.4-postgis”软件包,而不是“postgresql postgresql-contrib”. 我启动了服务器使用: postgres@lucid32:/home/vagrant$/etc/init.d/postgresql-8.4 start 连接到vagrant实例时,我可以使用psql连接到实例而不会出现问题. 在我的Vagrantfile中,我已添加: config.vm.forward_port 5432,5432 但是当我尝试从localhost运行psql时,我得到: psql: could not connect to server: Connection refused Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? 我确定我错过了一些简单的事情.有任何想法吗? 更新: 我发现了对这样一个问题的引用,并且文章建议使用: psql -U postgres -h localhost 我得到了: psql: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
您提到的博客文章中的说明根本不适用于ubuntu:它们使用安装自编译服务器的部分,这些服务器与打包版本不能很好地混合.
不应该创建/usr/local / pgsql / data并将initdb运行到该目录,因为ubuntu包使用/ var / lib / postgresql /< pg-version-number> /< cluster-name>并代表用户运行initdb. 提到“/tmp/.s.PGSQL.5432”的错误表明此文件的预期位置不正确(对于ubuntu).它应该在/ var / run / postgresql中.这可能是由于使用与ubuntu不兼容的参数手动运行initdb. 要编辑以启用非本地连接的postgresql.conf和pg_hba.conf文件应位于/etc/postgresql/8.4/main内,而不是/usr/local / pgsql / data. /etc/init.d/postgresql-8.4应该由root(或/etc/init.d中的其他所有内容)启动,而不是由postgres用户启动. PGD??ATA不应该手动设置,因为它确实妨碍了ubuntu postgres包的工作方式. 我的答案是清除并重新安装postgresql-8.4软件包,而不遵循博客文章中的任何说明. postgresql-8.4-postgis依赖于postgresql-8.4所以它也将被删除.另外,请确保在/etc/bash.bashrc中撤消PGDATA的设置. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |