1

I am creating a batch file that will automatically run the following commands:

SET PATH=%PATH%;C:\Program Files\PostgreSQL\9.0\bin
initdb -D "data" -U USERNAME –E UTF-8
pg_ctl -D "data" -l logfile start
createdb -E UTF-8 -e -O USERNAME -U USERNAME -w sampledb

When I get to this point, it prompts for a password -- is there a way I can hardcode this password in, so I don't have to manually enter it in?

Thanks! Any insight would be appreciated.

2
  • if you simply type 'createdb' does it show you the flags that you can pass in? I know in mysql you can pass a -p'password' without the ' and it will do the password for you. Commented Nov 16, 2011 at 19:32
  • 2
    postgresql.org/docs/current/static/libpq-pgpass.html Commented Nov 16, 2011 at 19:56

1 Answer 1

3

You can specify PGPASSWORD as an environment variable for many commands, e.g:

PGPASSWORD=foo pg_...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.