我已经安装了 PostgreSQL,但是当我运行命令时postgres
在Windows CMD中
它给出以下错误:
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
即使运行命令后
-
initdb postgres
按照维护类似问题 https://superuser.com/questions/442554/postgresql-homebrew-installation-lacks-config-files
-
postgres -D C:\Program Files\PostgreSQL\data\
给了我以下输出:
2016-09-28 15:04:57 PDT LOG: could not bind IPv6 socket: Only one usage of each socket address (protocol/network address/port) is normally permitted.
2016-09-28 15:04:57 PDT HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2016-09-28 15:04:57 PDT LOG: could not bind IPv4 socket: Only one usage of each socket address (protocol/network address/port) is normally permitted.
2016-09-28 15:04:57 PDT HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2016-09-28 15:04:57 PDT WARNING: could not create listen socket for "*"
2016-09-28 15:04:57 PDT FATAL: could not create any TCP/IP sockets
2016-09-28 15:04:57 PDT LOG: database system is shut down
正如错误所示,要启动 postgresql 集群,您必须设置数据文件夹的路径。大概是这样的:
postgres -D "C:\Program Files\PostgreSQL\data\"
但使用pg_ctl
反而postgres
被推荐:
pg_ctl -D "C:\Program Files\PostgreSQL\data\" start
不要忘记检查 postgres 文档如何启动服务器 https://www.postgresql.org/docs/9.1/static/server-start.html and 如何使用pg_ctl https://www.postgresql.org/docs/9.3/static/app-pg-ctl.html.
通常,postgres 安装程序会创建一个服务/守护进程,因此不需要手动启动服务器。所以如果你收到类似的错误
Is another postmaster already running on port 5432?
这可能意味着服务器已经在运行。尝试使用连接到它psql
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)