简体   繁体   English

PostgreSQL无法连接到数据库

[英]PostgreSQL cannot connect to database

I'm on Ubuntu and trying to connect to postgresql by any means, ie running psql throws: 我在Ubuntu上,尝试通过任何方式连接到postgresql,即运行psql throws:

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

sudo /etc/init.d/postgresql restart fixes the problem, however, once I restart the computer, I always have to type the line into terminal all over again. sudo /etc/init.d/postgresql restart解决了该问题,但是,一旦我重新启动计算机,我总是必须再次在终端上键入该行。 Is there any way to fix this problem, so I don't have to type the line? 有什么办法可以解决此问题,所以我不必键入行?

Do you kill the server before restarting the computer? 在重新启动计算机之前,您是否杀死服务器? If you're just restarting the computer, or if the battery dies while your server is running, you more than likely will run into this issue. 如果您只是重新启动计算机,或者在服务器运行时电池没电了,则很可能会遇到此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM