postgresql - 从批处理文件中的文件输入问题

标签 postgresql input batch-file

当它询问时,我需要为此命令输入两次密码

createuser -h localhost -P -p 5432 -s -d -r -e postgres 

我试过了

createuser -h localhost -P -p 5432 -s -d -r -e postgres < temp.txt

其中 temp.txt 包含

password
password

它仍然要求输入密码

有什么建议吗?

最佳答案

createuser程序可能会自己连接到终端而不是从其标准输入中读取,这是涉及密码的常见行为。使用 SQL CREATE ROLE 可能会有更好的运气而不是 createuser:

echo "CREATE ROLE postgres CREATEROLE CREATEDB SUPERUSER PASSWORD 'password';" \   
    | psql -h localhost -p 5432 databasename

其中“databasename”是您的数据库的名称。

来自fine manual :

createuser is a wrapper around the SQL command CREATE ROLE. There is no effective difference between creating users via this utility and via other methods for accessing the server.

关于postgresql - 从批处理文件中的文件输入问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5893056/

相关文章:

postgresql - GreenPlum 子字符串 - 获取长文本的一部分

sql - SQL中时间序列数据的导数/时间差

batch-file - 将所有奇数文件移动到一个文件夹

batch-file - 使用 CMD 将文本文件中的所有 CR 转换为 CRLF

windows - 如何根据名称和日期更改多个文件名

sql - 创建一个不返回任何内容的用户定义函数

sql - PostgreSQL 9.5 在多次出现的键上插入数据

javascript - 有没有办法直接绑定(bind)到监视箭头的 "number"输入字段?

python - Input() 阻止 IDE 停止程序

excel - 如何选择表格列中最后一个填充的单元格