我在 ubuntu 中安装了 postgresql,但不清楚如何为本地服务器(apache)启动或配置它
我尝试输入(在终端提示符下)
psql
但我收到了这个错误信息:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432
我习惯使用 mysql,只需输入
mysql -u username -p password
我也刚刚尝试重新安装 postgresql,这是我的错误消息:
Setting up postgresql-9.1 (9.1.3-0ubuntu0.11.10) ...
* Starting PostgreSQL 9.1 database server * The PostgreSQL server failed to start. Please check the log output:
2012-03-05 10:57:06 EST LOG: invalid connection type "localhost"
2012-03-05 10:57:06 EST CONTEXT: line 76 of configuration file "/etc/postgresql/9.1/main/pg_hba.conf"
2012-03-05 10:57:06 EST LOG: invalid connection type "METHOD"
2012-03-05 10:57:06 EST CONTEXT: line 100 of configuration file "/etc/postgresql/9.1/main/pg_hba.conf"
2012-03-05 10:57:06 EST FATAL: could not load pg_hba.conf
[fail]
invoke-rc.d: initscript postgresql, action "start" failed.
dpkg: error processing postgresql-9.1 (--configure):
subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
dpkg: dependency problems prevent configuration of postgresql:
postgresql depends on postgresql-9.1; however:
Package postgresql-9.1 is not configured yet.
dpkg: error processing postgresql (--configure):
dependency problems - leaving unconfigured
答案1
通常在检查其他任何东西之前我会检查 PostgreSQL 是否正在运行:
ps -fu postgres
如果它正在运行,您将需要编辑/etc/postgres/postres.conf
,/etc/postgres/pg_hba.conf
以正确配置它。
您可以看到这一页更多细节。
如果服务器没有运行,您可能必须尝试启动它:
sudo /etc/init.d/postgresql-<version> restart
如果问题仍然存在,那么我会开始检查日志来排除故障。
答案2
问题是 PostgreSQL 已停止,因此必须启动它。尝试以下命令启动 PostgreSQL:
要检查状态:
sudo /etc/init.d/postgres 状态
开始:
sudo /etc/init.d/postgresql 启动