Question

I have a postgresql demon on my virtual Linux box, and just installed pgAdmin III on the Windows machine. Now I'd like to configure the first connection.

What I did so far:

  • I edited /etc/postgresql/9.1/main/pg_hba.conf and added a line to make the demon accept connections from my Windows machine:
    host all all 192.168.123.45/32 md5
  • I set a shell passphrase for the system user postgres (sudo passwd postgres)
  • Edit: this seems to be irrelevant
    I copied /usr/share/postgresql/9.1/pg_service.conf.sample to /etc/postgresql-common/pg_service.conf and uncommented the sample service, giving me
    [postgres]
    dbname=postgres
    user=postgres
  • Edit: this seems to be irrelevant
    I put a line into /etc/environment to point to the pgservice.conf file:
    PGSERVICEFILE=/etc/postgresql-common/pg_service.conf
    (which works; when I duplicated the PuTTY session, it had this variable)
  • I restarted the database server after each change:
    sudo /etc/init.d/postgresql restart
  • Finally, I restartet the Linux box,

The server seems to have restarted successfully:

[ ok ] Restarting PostgreSQL 9.1 database server: main.

However, when I try to connect to the service, pgAdmin III gives me an error message:
Error connecting to the server: definition of service "postgres" not found.

dmesg | grep postgres gives me a single line:

[   18.054965] postgres (2242): /proc/2242/oom_adj is deprecated, please use /proc/2242/oom_score_adj instead.

I have no clue whether postgresql uses my pq_service.conf at all, or whatever else is the problem; any help is appreciated ...

Edit: My original question, "How can I know whether postgresql uses my pg_service.conf file?", seems to be answered - it simply doesn't. I still can't connect; but now the question doesn't match the error messages anymore.

I removed the "Service" entry from my "New Server Registration" data. Now I get another error - something like "password authentication for user >>postgres<< failed". I'm quite sure the password is correct - I just set it ... and I tested it by commenting out my ssh key from the authorized_keys file.

I'd happily connect with my ssh key, but this seems to be difficult as well. With PuTTY, my key is taken from Pageant, and I'm logged in without any problem; pgAdmin talks about "SSH tunnelling", but I normally don't need tunnels for this local machine ...

I tried to create a tunnel anyway.

  • PuTTY session:
    • Source port is 5432
    • destination is my-vbox.host.name:5432
  • In pgAdmin, "SSH Tunnel":
    • Username postgres
    • using Identity file
    • Tunnel host localhost → error:
      "SSH error: Could not connect to socket with error code 10051"
    • Tunnel host localhost:5432 → error:
      "SSH error: Unable to resolve host: localhost:5432"
    • Tunnel host 127.0.0.1:5432 → error:
      "SSH error: Unable to resolve host: 127.0.0.1:5432"

How the heck is this supposed to be configured?!

Was it helpful?

Solution

I finally managed to connect as db user tobias (I never had problems to connect locally, with 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

After doing this, I could connect as tobias, using the password just set. The "Maintenance DB" happens to be template1; I didn't try to change this.

For further reference - I activated log_connections in /etc/postgresql/9.1/main/postgresql.conf and watched the log:

sudo tail -f /var/log/postgresql/postgresql-9.1-main.log
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top