1

When I use postgres, the job works, but when I use ydz2, the job doesn't work:

Couldn't get a connection to the database

Both of them are my local database.

Job Step

enter image description here

Job Step Statistics

enter image description here

Where should I configure it?

Thank you.

Jim Jones
  • 18,404
  • 3
  • 35
  • 44
MLM520
  • 59
  • 2
  • 1
    hey @ThomasFlinkow I would also normally downvote such a question, but considering it concerns pgAgent, it is rather helpful to show some screenshots. +1 for the thorough evaluation :-) – Jim Jones Apr 17 '18 at 10:33
  • 1
    @JimJones you're right, I removed the downvote. The pictures do actually help in this case. Also, when I saw the post in review, the pictures didn't show, but rather they were links only. – Thomas Flinkow Apr 17 '18 at 10:37

1 Answers1

2

It seems pgagent cannot connect to the database, which might be because you didn't provide the required credentials. Make sure your .pgpass file is properly configured.

Assuming you're using the user postgres for pgAgent and that you have installed the extension in the database postgres:

$ sudo su - postgres
$ cd ~
$ nano .pgpass

Insert the following text and save the document:

localhost:5432:*:postgres:[postgres_password]

This line basically tells the database connection to use the given password for the user postgres to connect to any (*) database on the server localhost listening on the port 5432.

Once you're done with the .pgpass, give the file the proper permissions:

$ chmod 0600 .pgpass

You might need to restart pgAgent (not sure if it's necessary):

$ pgagent hostaddr=localhost dbname=postgres user=postgres
Jim Jones
  • 18,404
  • 3
  • 35
  • 44