我的虚拟Linux机器上有一个postgresql
恶魔,只是在Windows机器上安装了pgAdmin III。现在我想配置第一个连接。
到目前为止我做了什么:
/etc/postgresql/9.1/main/pg_hba.conf
并添加了一行以使恶魔接受来自我的Windows机器的连接:host all all 192.168.123.45/32 md5
postgres
设置了一个shell密码(sudo passwd postgres
)/usr/share/postgresql/9.1/pg_service.conf.sample
复制到/etc/postgresql-common/pg_service.conf
并取消注释了示例服务,并给了我
[postgres的] /etc/environment
中添加一行指向pgservice.conf
文件:PGSERVICEFILE=/etc/postgresql-common/pg_service.conf
sudo /etc/init.d/postgresql restart
服务器似乎已成功重启:
[ ok ] Restarting PostgreSQL 9.1 database server: main.
但是,当我尝试连接到该服务时,pgAdmin III给出了一条错误消息:
连接到服务器时出错:未找到服务“postgres”的定义。
dmesg | grep postgres
给了我一行:
[ 18.054965] postgres (2242): /proc/2242/oom_adj is deprecated, please use /proc/2242/oom_score_adj instead.
我不清楚postgresql
是否完全使用我的pq_service.conf
,或其他问题;任何帮助表示赞赏...
修改
我原来的问题“How can I know whether postgresql uses my pg_service.conf file?
”似乎得到了解答 - 它根本就没有。我仍然无法连接;但现在问题不再与错误信息相符。
我从“新服务器注册”数据中删除了“服务”条目。现在我收到了另一个错误 - 例如“用户的密码验证>> postgres<< failed”。我非常确定密码是正确的 - 我只是设置它......我通过从authorized_keys
文件中注释掉我的ssh密钥来测试它。
我很乐意与我的ssh键连接,但这似乎也很困难。使用PuTTY,我的密钥取自Pageant,我没有任何问题登录; pgAdmin谈到“SSH隧道”,但我通常不需要这台本地机器的隧道......
无论如何我试图建立一条隧道。
5432
my-vbox.host.name:5432
postgres
localhost
→错误:SSH error: Could not connect to socket with error code 10051
”localhost:5432
→错误:SSH error: Unable to resolve host: localhost:5432
”127.0.0.1:5432
→错误:SSH error: Unable to resolve host: 127.0.0.1:5432
”这应该如何配置?!
答案 0 :(得分:4)
我终于成功连接为db user tobias
(我从来没有遇到过本地连接问题psql
)。
# sudo -u postgres psql postgres
psql (9.1.9)
Type "help" for help.
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication | {}
tobias | Superuser | {}
postgres=# ALTER USER tobias WITH PASSWORD 's3cr3t';
ALTER ROLE
执行此操作后,我可以使用刚设置的密码以tobias
连接。
"维护DB"碰巧是template1
;我并没有试图改变它。
如需进一步参考 - 我在log_connections
中激活了/etc/postgresql/9.1/main/postgresql.conf
并观看了日志:
sudo tail -f /var/log/postgresql/postgresql-9.1-main.log