I try to run an application where its database on postgresql. It won't work and I'm getting the following error whenever I try to interact with the Postgres service:
could not connect to server: Aucun fichier ou dossier de ce type
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432`
I checked if Postgresql service is running
sudo systemctl status postgresql
postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enab
Active: active (exited) since Thu 2019-04-04 10:28:27 +01; 58min ago
Main PID: 1212 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 3522)
CGroup: /system.slice/postgresql.service
avril 04 10:28:27 ubuntu systemd[1]: Starting PostgreSQL RDBMS...
avril 04 10:28:27 ubuntu systemd[1]: Started PostgreSQL RDBMS.
checked the content of the socket unix connection
ls /var/run/postgresql/
got this empty folder
brahim@ubuntu:/var/log/postgresql$ ls /var/run/postgresql/
10-main.pg_stat_tmp
checked the content of the data directory
ls /var/lib/postgresql/10/main/
it contains the following
base pg_logical pg_serial pg_subtrans pg_wal
global pg_multixact pg_snapshots pg_tblspc pg_xact
pg_commit_ts pg_notify pg_stat pg_twophase
postgresql.auto.conf pg_dynshmem pg_replslot pg_stat_tmp
PG_VERSION postmaster.opts
the file postgresql.conf has the following configuration
# - Connection Settings -
#listen_addresses = 'localhost'
port = 5432
max_connections = 100
unix_socket_directories = '/var/run/postgresql'
I tried to uncomment the listen_addresses instruction and it didn't work, also I've tried with '*' for all, same thing
the postgresql file log has
2019-04-04 12:17:57.765 +01 [942] LOG: listening on IPv4 address "127.0.0.1", port 5432
2019-04-04 12:17:57.767 +01 [942] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-04-04 12:17:58.190 +01 [971] LOG: database system was shut down at 2019-04-03 20:19:54 +01
2019-04-04 12:17:58.192 +01 [971] PANIC: replication checkpoint has wrong magic 1886413116 instead of 307747550
2019-04-04 12:17:59.900 +01 [942] LOG: startup process (PID 971) was terminated by signal 6: Aborted
2019-04-04 12:17:59.900 +01 [942] LOG: aborting startup due to startup process failure
2019-04-04 12:17:59.902 +01 [942] LOG: database system is shut down
I am running postgresql 10.6 any thoughts
initdb
then restore your backup../initdb -D /usr/local/pgsql/data
the creation was done successfully, but i try to start it with the fallowingsudo ./pg_ctl -D /usr/local/pgsql/data -l logfile start
but i get permission denied error #pg_ctl: cannot be run as root Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process# i changed the owner of the /usr/local/pgsql/data/ to the usr brahimls - la /usr/local/pgsql/data/
got this #total 8 drwxr-xr-x 2 brahim brahim 4096 avril 4 13:55 . drwxr-xr-x 3 root root 4096 avril 4 13:55