我关注了these instructions将 Postgres 数据目录从 C:\Users\username\Documents\dir\postgres96_data 移动到 C:\Users\username\Documents\postgres96_data。
现在 Postgres 服务将无法启动。尝试手动启动它会产生以下消息(从 pt-br 自由翻译):
"The postgres-x64-9.6 service on Local Computer started then stopped. Some services stop automatically if they are not beeing used by other services or programs."
我尝试(成功)使用命令在 cmd.exe 中启动数据库
"C:\Program Files\PostgreSQL\9.6\bin\pg_ctl.exe" start -D "C:\Users\username\Documents\postgres96_data" -w
日志是:
2017-02-20 07:33:26 BRT LOG: database system was interrupted; last known up at 2017-02-18 09:52:00 BRT
2017-02-20 07:33:27 BRT FATAL: the database system is starting up
...
2017-02-20 07:35:10 BRT FATAL: the database system is starting up
2017-02-20 07:36:19 BRT LOG: database system was not properly shut down; automatic recovery in progress
2017-02-20 07:36:19 BRT LOG: invalid record length at 6/438EBB88: wanted 24, got 0
2017-02-20 07:36:19 BRT LOG: redo is not required
2017-02-20 07:36:19 BRT LOG: MultiXact member wraparound protections are now enabled
2017-02-20 07:36:19 BRT LOG: sistema de banco de dados está pronto para aceitar conexões [database system is ready to accept conections, free translation]
2017-02-20 07:36:21 BRT LOG: autovacuum launcher started
之前的研究
最佳答案
您需要更改服务定义。该服务仍在使用旧的数据目录。
要更改服务,请将其删除并重新创建:
pg_ctl unregister -N postgres-x64-9.6
然后使用新的数据目录重新创建它:
pg_ctl register -N postgres-x64-9.6 -D "C:\Users\username\Documents\postgres96_data"
这假设您使用的是默认安装,其中服务使用内置“网络帐户”运行。如果不是这种情况,您需要在注册服务时使用 -U
和 -P
参数提供必要的用户名和密码。
关于windows - 移动 pgdata 目录后,Postgres 服务将无法在 Windows 中启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42342831/