当它询问时,我需要为此命令输入两次密码
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/