PostgreSQL error: could not connect to database template1: could not connect to server: No such file or directory

僤鯓⒐⒋嵵緔 提交于 2020-01-03 06:53:40

问题


I need to create database.

First I run: sudo su - postgres, then: createdb test

And I keep getting this error:

createdb: could not connect to database template1: 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"

This is unexpected, I have never encountered any problems with psql, but this time I don't get what is wrong. And there is no external server, I am connected locally.

I am running on Ubuntu.


回答1:


The error message suggests:

Is the server running locally

and according to the result of ps -ef | grep "post" posted in the comments, the answer is a definitive No, the server processes are not there, the server is not running.

That fact that you write i have never encountered any problems with psql, suggests that it was installed and working before, in that case look at the most recent log file inside /var/log/postgresql to check for any fatal error message indicating why the server didn't start.



来源:https://stackoverflow.com/questions/30095546/postgresql-error-could-not-connect-to-database-template1-could-not-connect-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!