Postgresql: Scripting psql execution with password

后端 未结 16 2526
谎友^
谎友^ 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 18:55

    This also works for other postgresql clis for example you can run pgbench in non-interactive mode.

    export PGPASSWORD=yourpassword
    /usr/pgsql-9.5/bin/pgbench -h $REMOTE_PG_HOST -p 5432 -U postgres -c 12 -j 4 -t 10000 example > pgbench.out 2>&1 &
    

提交回复
热议问题