gpt4 book ai didi

postgresql - postgres、psql 和一个 bat 文件

转载 作者:行者123 更新时间:2023-11-29 13:06:11 26 4
gpt4 key购买 nike

我正在兜圈子,所以需要一些帮助。

我希望能够通过 bat 文件对数据库运行 .sql,这是一个计划任务。但是,当我手动运行 bat 文件时,系统会提示我输入密码。我输入密码,然后被告知....

"psql: FATAL: password authentication failed for user "(my windows login)"
'-h' is not recognised as an internal or external command,
operable program or batch file.

此刻我的 bat 读...

@echo off
"D:\Program Files (x86)\PostgreSQL\9.1\bin\psql.exe"
-h localhost -U postgres -d database_name -f D:/scripts/SQL/test.sql
pause

首先,我需要添加什么 cmd 来填充密码请求

为了让它加载 .sql,我对语句的其余部分做错了什么

谢谢

最佳答案

通过将这一行添加到您的配置文件 (pg_hba.conf),您可以告诉 postgres 允许无需身份验证的本地连接

local      <database>  <user>  trust

http://www.postgresql.org/docs/9.1/static/auth-pg-hba-conf.html

关于postgresql - postgres、psql 和一个 bat 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11016730/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com