简体   繁体   English

更改PostgreSQL数据目录

[英]change PostgreSQL data directory

I installed postgres 9.5 quite a while ago, and since a few months ago have upgraded to 9.6 and used that. 我很早以前安装了postgres 9.5,自几个月前已经升级到9.6并使用了它。 Recently I shut down my computer and restarted postgres, but when I connect to the 9.6 server and run 最近,我关闭了计算机并重新启动了postgres,但是当我连接到9.6服务器并运行时

SHOW data_directory

it is showing that my data directory is under the 9.5 folder. 它表明我的数据目录位于9.5文件夹下。 As a result, none of my recent databases are available because I am linked to the old version of postgres. 结果,由于我已链接到旧版本的postgres,因此我最近的数据库都不可用。 What happened and how can I change it back? 发生了什么事,我该如何更改?

在此处输入图片说明

It would seem that your machine has started your previous instance. 看来您的计算机已经启动了先前的实例。 You need to stop the 9.5 server and start the 9.6. 您需要停止9.5服务器并启动9.6。

On *nix OS you will need to use the PG_CTL command. 在* nix操作系统上,您将需要使用PG_CTL命令。 eg: 例如:

PG_CTL -D [enter path for 9.5 data directory here] stop
PG_CTL -D [enter path for 9.6 data directory here] start

This should stop 9.5 and start 9.6. 这应该停止9.5,然后开始9.6。 You can confirm this by doing: 您可以通过执行以下操作来确认这一点:

PG_CTL -D [enter path for 9.5 data directory here] status

should return stopped. 应该返回停止。

PG_CTL -D [enter path for 9.6 data directory here] status

should return running. 应该返回运行。

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

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