首页 > 解决方案 > 无法在 Windows CMD 中使用 pg_ctl?

问题描述

pg_ctl status
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.

C:\Users\Think>pg_ctl --help
pg_ctl is a utility to initialize, start, stop, or control a PostgreSQL server.

我不知道 pg_data 目录在哪里,我在 windows 设置中将 C:\Users\Think\Desktop\postgres\data 设置为用户变量系统变量。但仍然无法正常工作。在bin目录下,有 pg_ctl.exe 文件。

环境变量

标签: postgresqlcmddatabase-administration

解决方案


您需要使用该-D选项来告诉pg_ctl您的数据目录在哪里:

pg_ctl -D "Q:\path\to\datadir"

如果你已经创建了一个数据目录,你应该可以在cmd.exe其中找到它

dir C:\ /s /b | find PG_VERSION

如果它打开C:

如果您只是单击安装程序,它可能在

C:\Program Files\PostgreSQL\12\data

推荐阅读