0

After installation via $ sudo apt install postgresql I haven't managed to setup user and create database, in both cases it stated:

$ sudo -u postgres createuser --createdb dreu007

could not change directory to "/home/dreu007": Permission denied
createuser: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
$ sudo -u postgres createdb --owner=dreu007 hexlet

could not change directory to "/home/dreu007": Permission denied
createdb: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?

Then I checked:

$ psql -U postgres

psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?

Basic attempt to restart $ sudo service postgresql restart didn't change anything.

Checked process:

$ ps aux | grep postgres

dreu007    16844  0.0  0.0  12804  4192 pts/1    S+   10:04   0:00 man postgres
dreu007    19505  0.0  0.0  10836  2352 pts/2    S+   10:33   0:00 grep --color=auto postgres

Looks like nothing is running.

I have tried to follow these threads: 1 & 2 and met difficulties to locate pg_hba.conf in /etc/postgresql/ The directory is empty. Same issue here /var/run/postgresql/, empty.

psql (PostgreSQL) 14.8 (Ubuntu 14.8-0ubuntu0.22.04.1)

DREU007
  • 1
  • 2
  • You don't say how you think you installed it? (because it clearly isn't installed) If you install via "apt" it will create any configuration and data directories you require and initialise everything for you – Richard Huxton Jul 03 '23 at 06:51
  • @RichardHuxton, updated post, I did `$ sudo apt install postgresql` – DREU007 Jul 03 '23 at 07:06
  • If you run `dpkg-query --list 'postgresql*' | grep ii` it should show "postgresql-14" listed as installed, but I'm guessing it doesn't – Richard Huxton Jul 03 '23 at 10:40
  • @RichardHuxton, `$ dpkg-query --list 'postgresql' | grep ii` `ii postgresql 14+238 all object-relational SQL database (supported version)` – DREU007 Jul 03 '23 at 11:54

1 Answers1

0

The problem was with locale after the purge and repetetive installation, I have noticed this error:

Error: The locale requested by the environment is invalid:
  LANG: C.UTF-8
  LC_ADDRESS: hy_AM
  LC_IDENTIFICATION: hy_AM
  LC_MEASUREMENT: hy_AM
  LC_MONETARY: hy_AM
  LC_NAME: hy_AM
  LC_NUMERIC: hy_AM
  LC_PAPER: hy_AM
  LC_TELEPHONE: hy_AM
  LC_TIME: hy_AM
Error: could not create default cluster. Please create it manually with

  pg_createcluster 14 main --start

or a similar command (see 'man pg_createcluster').

So I followed it with: $ sudo pg_createcluster 14 main --start and it created new PostgreSQL cluster.

DREU007
  • 1
  • 2