Postgresql: Scripting psql execution with password

后端 未结 16 2435
谎友^
谎友^ 2020-11-28 18:54

How can I call psql so that it doesn\'t prompt for a password?

This is what I have:

psql -Umyuser < myscript.sql         


        
16条回答
  •  抹茶落季
    2020-11-28 19:20

    If you're having problems on windows like me (I'm using Windows 7 64-bit) and set PGPASSWORD=[Password] did not work.

    Then, as Kavaklioglu said in one of the comments,

    export PGPASSWORD=[password]
    

    You will need to save this at the top of the file, or before any usage so its set before being called.

    Certainly does work on windows :)

提交回复
热议问题