Postgres - 移动数据文件夹

Postgres - Moving Data Folder

我想移动我的 Ubuntu 服务器上的 PostgreSQL 数据文件夹,我正在按照 this tutorial 移动它。

我能够移动它,并更新我的 conf 文件以指向新位置。

当我转到 运行 Postgres 时,它启动了,但是当我尝试通过

连接时
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"?

知道发生了什么事吗?它说它是 运行ning。

完成移动 PostgreSQL 数据目录后。不要忘记 restart PostgreSQL 服务。

通过命令ps -ef | grep postgres检查PostgreSQL状态。 -D 参数值应该是新的目录位置。

错误/var/run/postgresql/.s.PGSQL.5432这意味着您的 PostgreSQL 服务没有正确启动或启动时失败。