问题描述
我使用教程,但它无法连接到服务器。
我使用此命令登录到Postgres会话:
I installed postgreSQL using this tutorial, but it can't connect to server.I use this command to login to Postgres session:
sudo -u postgres psql
但我收到此错误:
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"?
我在Stackoverflow中进行搜索,发现,提示我必须使用以下命令删除 postmaster.bid 文件:
I searched in Stackoverflow and found an answer that says I have to remove postmaster.bid file using this command:
rm /usr/local/var/postgres/postmaster.pid
但它也会引起错误:
rm: cannot remove '/usr/local/var/postgres/postmaster.pid': No such file or directory
这些是 local 目录的内容:
bin etc games include lib man n sbin share src
那么,如何找到 postmaster.bid 文件并将其删除? (如果是解决方案)
So, how can I find the postmaster.bid file and remove it? (If it's the solution)
我的操作系统是Ubuntu 16.04。
推荐答案
我在Ubuntu 18.04上遇到了相同的问题,找不到完整的答案,所以我做了以下工作:
I faced this same issue on Ubuntu 18.04 and couldn't find a comprehensive answer so I did the following:
-
完全卸载的Postgresql:
Uninstalled Postgresql completely :
sudo apt-get --purge remove postgresql-11 postgresql-client-11 postgresql-client-common postgresql-common postgresql-contrib postgresql-contrib-11
使用以下命令重新安装:
Reinstalled using the following commands:
sudo tee /etc/apt/sources.list.d/pgdg.list <<END
deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
END
wget https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo apt-key add ACCC4CF8.asc
sudo apt-get update
sudo apt-get install postgresql-11
验证postgresql是否已备份并正确运行:
Verify that postgresql is backup and running correctly:
sudo service postgresql status
现在,当我运行 su -postgresql psql
,错误消失了。
Now when I run su -postgresql psql
, the error is gone.
这篇关于Postgres无法连接到Ubuntu 16.04上的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!