首页 文章

如何从任何地方运行PostgreSQL的批处理文件?

提问于
浏览
0

我正在尝试为PostgreSQL数据库和服务器运行批处理文件我正在使用这个:

@ECHO ON
@SET PATH="%~dp0";%PATH%
@SET PGDATA=%~dp0\data
@SET PGUSER=postgres
@SET PGPORT=5432
@SET PGLOCALEDIR=%~dp0\share\locale
"%~dp0initdb" -U postgres -D %~dp0/data -E UTF8
"%~dp0pg_ctl" -w -D "%~dp0/data" -l logfile start
psql.exe -U postgres -f C:\pgsql\bin\db_create.sql postgres
"%~dp0pg_ctl" -D "%~dp0/data" stop

如果批处理文件和postgres文件夹的目录位于以下内容,这可以正常工作:

C:\ pgsql \ bin

但如果批处理文件的目录和postgres文件夹在其他地方,例如:

C:\ Program Files(x86)\ My App \ My App \ bin

批处理不起作用,并给我一个错误:

enter image description here

1 回答

  • 2

    你没有引用你的路径:

    "%~dp0initdb" -U postgres -D "%~dp0/data" -E UTF8
                                 ^----------^---missing
    

    如果你真的读过错误信息,“太多的参数,首先是'文件'你已经看过了 .

相关问题