Psql serverga ulana olmadi: bunday fayl yoki katalog yo'q, 5432 xato?

Vagrant mashinamda psql ni ishlatishga harakat qilaman, lekin men bu xatoni qabul qilaman:

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"?

Note: Vagrant 1.9.2 Box: ubuntu/trusty64, https://atlas.hashicorp.com/ubuntu/boxes/trusty64

EDIT Commands I've used in order to install and run postgres:

  • sudo apt-get update
  • sudo apt-get o'rnatish postgresql
  • sudo suv postgres
  • ni bosing
  • psql-postgres -U postgres
28
Siz hali bu xatoni tuzatdingizmi?
qo'shib qo'ydi muallif Toan Tran, manba
Siz hali bu xatoni tuzatdingizmi?
qo'shib qo'ydi muallif Toan Tran, manba
Bu men uchun ishlaydigan javob bo'ldi: askubuntu.com/a/824325/733901
qo'shib qo'ydi muallif Bruno Louvem Azeredo, manba
Bu men uchun ishlaydigan javob bo'ldi: askubuntu.com/a/824325/733901
qo'shib qo'ydi muallif Bruno Louvem Azeredo, manba

12 javoblar

Men pg_hba.conf faylimning konfiguratsiyasi bilan bog'liq bo'lgan (masalan, /etc/postgresql/9.6/main ) ushbu muammoga duch kelganman. Marhamat, 9,6 men foydalanadigan postgresql versiyasi.

Xatoning o'zi postgresql noto'g'ri konfiguratsiyasi bilan bog'liq bo'lib, bu server ishga tushishidan oldin ishdan chiqishiga sabab bo'ladi.

Men ushbu ko'rsatmalarga amal qilishni maslahat beraman:

  1. Certify that postgresql service is running, using sudo service postgresql start
  2. Run pg_lsclusters from your terminal
  3. Check what is the cluster you are running, the output should be something like:

    Version - Cluster Port Status Owner Data directory

    9.6 ------- main -- 5432 online postgres /var/lib/postgresql/9.6/main

    Disregard the '---' signs, as they are being used there only for alignment. The important information are the version and the cluster. You can also check whether the server is running or not on the status column.

  4. Copy the info from the version and the cluster, and use like so: pg_ctlcluster start, so in my case, using version 9.6 and cluster 'main', it would be pg_ctlcluster 9.6 main start
  5. If something is wrong, then postgresql will generate a log, that can be accessed on /var/log/postgresql/postgresql--main.log, so in my case, the full command would be sudo nano /var/log/postgresql/postgresql-9.6-main.log.
  6. The output should show what is the error.

    2017-07-13 16:53:04 BRT [32176-1] LOG: invalid authentication method "all"
    2017-07-13 16:53:04 BRT [32176-2] CONTEXT: line 90 of configuration file "/etc/postgresql/9.5/main/pg_hba.conf"
    2017-07-13 16:53:04 BRT [32176-3] FATAL: could not load pg_hba.conf

  7. Fix the errors and restart postgresql service through sudo service postgresql restart and it should be fine.

Buni topish uchun juda ko'p narsa izladim, kredit bu boradi pochta manzili .

Omadingiz yaxshiroq!

52
qo'shib qo'ydi

Men pg_hba.conf faylimning konfiguratsiyasi bilan bog'liq bo'lgan (masalan, /etc/postgresql/9.6/main ) ushbu muammoga duch kelganman. Marhamat, 9,6 men foydalanadigan postgresql versiyasi.

Xatoning o'zi postgresql noto'g'ri konfiguratsiyasi bilan bog'liq bo'lib, bu server ishga tushishidan oldin ishdan chiqishiga sabab bo'ladi.

Men ushbu ko'rsatmalarga amal qilishni maslahat beraman:

  1. Certify that postgresql service is running, using sudo service postgresql start
  2. Run pg_lsclusters from your terminal
  3. Check what is the cluster you are running, the output should be something like:

    Version - Cluster Port Status Owner Data directory

    9.6 ------- main -- 5432 online postgres /var/lib/postgresql/9.6/main

    Disregard the '---' signs, as they are being used there only for alignment. The important information are the version and the cluster. You can also check whether the server is running or not on the status column.

  4. Copy the info from the version and the cluster, and use like so: pg_ctlcluster start, so in my case, using version 9.6 and cluster 'main', it would be pg_ctlcluster 9.6 main start
  5. If something is wrong, then postgresql will generate a log, that can be accessed on /var/log/postgresql/postgresql--main.log, so in my case, the full command would be sudo nano /var/log/postgresql/postgresql-9.6-main.log.
  6. The output should show what is the error.

    2017-07-13 16:53:04 BRT [32176-1] LOG: invalid authentication method "all"
    2017-07-13 16:53:04 BRT [32176-2] CONTEXT: line 90 of configuration file "/etc/postgresql/9.5/main/pg_hba.conf"
    2017-07-13 16:53:04 BRT [32176-3] FATAL: could not load pg_hba.conf

  7. Fix the errors and restart postgresql service through sudo service postgresql restart and it should be fine.

Buni topish uchun juda ko'p narsa izladim, kredit bu boradi pochta manzili .

Omadingiz yaxshiroq!

52
qo'shib qo'ydi

Men bu savolni topgach, yo'qolgan va umidsiz bo'lgan har bir odam uchun buni yozyapman. Ba'zida ba'zi psotgresql bilan bog'liq konfiguratsiya fayllarini tahrirlash orqali faylning ruxsatini tasodifan o'zgartirish mumkin:

enter image description here

Pg_hba.conf ning ildizga tegishli ekanligini va foydalanuvchilar uni o'qimasligini bilib oling. Bu postgresning ushbu faylni ocholmaydigan sabablarga olib kelishi va shuning uchun serverni ishga tushirib bo'lmaydi, aslida ko'rilgan xatoni tashlaydi.

Yugurish orqali

sudo chmod + r pg_hba.conf ni bosing

Men ushbu faylni postgres foydalanuvchisiga yana bir marta kirib, undan so'ng ishga tushirishga muvaffaq bo'ldim

sudo xizmat postgresql boshlang

Serverni qaytadan ishga tushirishga muvaffaq bo'ldi.

2
qo'shib qo'ydi

Men bu savolni topgach, yo'qolgan va umidsiz bo'lgan har bir odam uchun buni yozyapman. Ba'zida ba'zi psotgresql bilan bog'liq konfiguratsiya fayllarini tahrirlash orqali faylning ruxsatini tasodifan o'zgartirish mumkin:

enter image description here

Pg_hba.conf ning ildizga tegishli ekanligini va foydalanuvchilar uni o'qimasligini bilib oling. Bu postgresning ushbu faylni ocholmaydigan sabablarga olib kelishi va shuning uchun serverni ishga tushirib bo'lmaydi, aslida ko'rilgan xatoni tashlaydi.

Yugurish orqali

sudo chmod + r pg_hba.conf ni bosing

Men ushbu faylni postgres foydalanuvchisiga yana bir marta kirib, undan so'ng ishga tushirishga muvaffaq bo'ldim

sudo xizmat postgresql boshlang

Serverni qaytadan ishga tushirishga muvaffaq bo'ldi.

2
qo'shib qo'ydi

/etc/postgresql/9.6/main/postgresql.conf portni tayinlanganligini ko'rsatadimi? Mening default Xubuntu Linux o'rnatishimga asosan, men maxfiy so'zni eslay olaman, shuning uchun eng yaxshi deb port = 5433 ni ko'rsatdi, lekin men ushbu faylda listen_addresses = 'localhost' kodini sharhlab berdim va line listen_addresses = '*' . Ehtimol, boshlang va u erda tekshiring. Bu yordamga umid qilaman.

2
qo'shib qo'ydi

/etc/postgresql/9.6/main/postgresql.conf portni tayinlanganligini ko'rsatadimi? Mening default Xubuntu Linux o'rnatishimga asosan, men maxfiy so'zni eslay olaman, shuning uchun eng yaxshi deb port = 5433 ni ko'rsatdi, lekin men ushbu faylda listen_addresses = 'localhost' kodini sharhlab berdim va line listen_addresses = '*' . Ehtimol, boshlang va u erda tekshiring. Bu yordamga umid qilaman.

2
qo'shib qo'ydi

Men ham xuddi shu masalaga ega edim, lekin bu erda javoblardan tashqari yordam berilmagan.

Qanday qilib uni (Mac)

  • Try to start postgresql with pg_ctl -D /usr/local/var/postgres start
  • Look for the Error Message that says something like FATAL: could not open directory "pg_tblspc": No such file or directory.
  • Create that missing directory mkdir /usr/local/var/postgres/pg_tblspc
  • Repeat from step one until you created all missing directories
  • When done and then trying to start postgresql again it might say FATAL: lock file "postmaster.pid" already exists
  • Delete postmaster.pid: rm /usr/local/var/postgres/postmaster.pid
  • Start postgres with: pg_ctl -D /usr/local/var/postgres start
  • Done ✨
1
qo'shib qo'ydi

Men ham xuddi shu masalaga ega edim, lekin bu erda javoblardan tashqari yordam berilmagan.

Qanday qilib uni (Mac)

  • Try to start postgresql with pg_ctl -D /usr/local/var/postgres start
  • Look for the Error Message that says something like FATAL: could not open directory "pg_tblspc": No such file or directory.
  • Create that missing directory mkdir /usr/local/var/postgres/pg_tblspc
  • Repeat from step one until you created all missing directories
  • When done and then trying to start postgresql again it might say FATAL: lock file "postmaster.pid" already exists
  • Delete postmaster.pid: rm /usr/local/var/postgres/postmaster.pid
  • Start postgres with: pg_ctl -D /usr/local/var/postgres start
  • Done ✨
1
qo'shib qo'ydi

/etc/hosts faylida biror narsa o'zgartirganimdek, xuddi shu narsa sodir bo'ldi. Uni 127.0.0.1 localhost ga o'zgartirgandan keyin u men uchun ishladi.

0
qo'shib qo'ydi

Ma'lumotlar bazasi menejerini oching va ushbu skriptni bajaring

update pg_database set datallowconn = 'true' where datname = 'your_database_name';
0
qo'shib qo'ydi

Ma'lumotlar bazasi menejerini oching va ushbu skriptni bajaring

update pg_database set datallowconn = 'true' where datname = 'your_database_name';
0
qo'shib qo'ydi

Agar VMda SQL db ni yaratishda men xato qilsam edi. Men /etc/postgresql/9.3/main/postgresql.conf ning umumiy qiymatining 75 foizini shared_buffers = 200MB ning standart qiymatini o'zgartirdim. Xo'sh, men o'sha RAMni VMda ajratishni unutganman. Yangi ma'lumotlar bazasini yaratish buyrug'ini berganimda, men xato qildim.

Chaqaloqni shishani (RAM) va prestodni berdi, u ishladi.

0
qo'shib qo'ydi