【发布时间】:2018-05-21 18:48:47
【问题描述】:
如何在 Windows 中通过命令行或 VBScript 为 PostgreSQL 10 (pgAdmin 4) 创建新数据库?
我在命令行中使用了以下命令:
pg_dump --dbname=postgresql://postgres:123@localhost:5432/myDB --format=p --clean
但是它返回了以下错误:
pg_dump: [archiver (db)] 连接到数据库“myDB”失败:无法连接到服务器:连接被拒绝 (0x0000274D/10061)
服务器是否在主机“localhost”(::1) 上运行并接受端口 5432 上的 TCP/IP 连接?
无法连接到服务器:连接被拒绝 (0x0000274D/10061)
服务器是否在主机“localhost”(127.0.0.1) 上运行并接受端口 5432 上的 TCP/IP 连接?
如何在“localhost”(127.0.0.1)中运行服务器?如何解决这个问题?
编辑: 另外,我也试过这个,
createdb --dbname=postgresql://postgres:123@localhost:5432/myDB --format=p --clean
得到了这个错误,
createdb: 非法选项 -- dbname=postgresql://postgres:123@localhost:5432/myDB
尝试“createdb --help”了解更多信息。
【问题讨论】:
-
嗯...是什么让您想到
pg_dump会创建 数据库?也许令人惊讶的是,PostgreSQL 数据库是使用createdb工具创建的。 -
Ansgar Wiechers,我已经更新了问题。可以查一下吗?
-
请自行阅读documentation。
标签: database windows postgresql cmd vbscript