我正在尝试在 ubuntu 上设置 postgres,但由于找不到 pg_hba.conf 的位置,因此无法继续
(Ubuntu 9.10 上的 Postgres 8.4)
我做了什么
- 通过 aptitude 设置 postgres
这给了我...
/usr/share/postgresql/8.4# aptitude install postgresql
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
The following NEW packages will be installed:
libreadline5{a} postgresql postgresql-8.4{a} postgresql-client-8.4{a} postgresql-client-common{a} postgresql-common{a}
0 packages upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/5,159kB of archives. After unpacking 18.8MB will be used.
Do you want to continue? [Y/n/?] Y
Writing extended state information... Done
Preconfiguring packages ...
Selecting previously deselected package libreadline5.
(Reading database ... 17490 files and directories currently installed.)
Unpacking libreadline5 (from .../libreadline5_5.2-6_amd64.deb) ...
Selecting previously deselected package postgresql-client-common.
Unpacking postgresql-client-common (from .../postgresql-client-common_101_all.deb) ...
Selecting previously deselected package postgresql-client-8.4.
Unpacking postgresql-client-8.4 (from .../postgresql-client-8.4_8.4.1-1_amd64.deb) ...
Selecting previously deselected package postgresql-common.
Unpacking postgresql-common (from .../postgresql-common_101_all.deb) ...
Selecting previously deselected package postgresql-8.4.
Unpacking postgresql-8.4 (from .../postgresql-8.4_8.4.1-1_amd64.deb) ...
Selecting previously deselected package postgresql.
Unpacking postgresql (from .../postgresql_8.4.1-1_all.deb) ...
Processing triggers for man-db ...
Setting up libreadline5 (5.2-6) ...
Setting up postgresql-client-common (101) ...
Setting up postgresql-client-8.4 (8.4.1-1) ...
update-alternatives: using /usr/share/postgresql/8.4/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode.
Setting up postgresql-common (101) ...
Setting up postgresql-8.4 (8.4.1-1) ...
update-alternatives: using /usr/share/postgresql/8.4/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode.
Setting up postgresql (8.4.1-1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Writing extended state information... Done
尝试以以下身份登录
su-postgres
其次是
createdb mytestdb
这失败了
could not connect to database postgres: 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"?
因此,我认为我需要在 pg_hba.conf 中启用本地连接,但我找不到它。因此,我创建了一个新文件,如下所示
sudo vim /etc/postgresql/8.4/main/pg_hba.conf
具有价值观
local all all ident
但重启服务后我仍然无法登录。我接下来该怎么做?
答案1
从输出来看,服务器似乎尚未启动。只需执行“/etc/init.d/postgresql-8.4 start”即可。
答案2
这通常是在您未指定主机而客户端尝试针对 ipv6 运行时发生的。您必须声明;
createdb mytestdb -h localhost
或者
createdb mytestdb -h 127.0.0.1