Command psql failed

I’m trying to set up a postgres database, but when I create it, I get bash error.

Config:

language: java
jdk: openjdk11

cache:
  directories:
    - $HOME/.m2

before_install:
  - sudo apt-get update
  - sudo apt-get --yes remove postgresql\*
  - sudo apt-get install -y postgresql-11 postgresql-client-11
  - sudo cp /etc/postgresql/{9.6,11}/main/pg_hba.conf
  - sudo service postgresql restart 11

before_script:
  - psql -c 'create database bank' -U postgres
  - psql -c 'create user "user"; grant all privileges on database bank to "user"' -U postgres

services:
  - postgresql

addons:
  postgresql: "11.2"

branches:
  only:
    - master

Result:

$ psql -c 'create database bank' -U postgres
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"?
The command "psql -c 'create database bank' -U postgres" failed and exited with 2 during .

Hey @Munoon,

Instead of having the addons section, try doing

services:
  - postgresql: "11.2"

See if that makes any difference.

1 Like

Still not working…