Postgresql:createdb 提示没有密码的用户输入密码

Moh*_*zar 6 database postgresql

我在 pgsql 中创建了一个没有密码的新用户。但是当我尝试为此用户创建数据库时,它会提示输入密码

>createuser -d -S -R -U postgres test1
Password:
>createdb -U test1 db1
Password:
Run Code Online (Sandbox Code Playgroud)

我已经尝试过超级用户密码,但它给了我错误:

createdb: could not connect to database template1: FATAL:  password authentication failed for user "test1"
Run Code Online (Sandbox Code Playgroud)

请帮忙,谢谢

小智 2

还有一种通过提示密码来创建用户的替代方法。您可以在创建用户时给出 -P 选项。喜欢:

创建用户-d -S -R -U postgres test1

  • 您能编辑一下您的答案吗?您的示例未显示实际的“-P”选项... (3认同)