By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

Error while running createdb from a batch file in windows xp

P: 7

I am installing postgreSQL 8.2 using batch files in windows xp machine.

I am installing postgres using postgresql-8.2.msi installer.
Installation was successful.

When i tried to run createdb command
using the following command from another batch file
"createdb -U dbname username"

command prompt asked me to enter password for the username

Is there a way to avoid this password prompt.

This command works good in windows 2000

Thanks in Advance,
Aug 17 '07 #1
Share this Question
Share on Google+
5 Replies

Expert 100+
P: 534
Unless you set up your database access with the "trust" option this prompt is probably asking for your password, not the password for the username you passing to the createdb command.

Look at pg_hba.conf file, or simply run something like psql -l - would you be prompted for password?

If this is the case you can either change your access mode to trust instead of password, or put something like this in your batch file:
set PGPASSWORD=my_password

Obviously you may need to consider the possible security issues arising from these actions.
Aug 18 '07 #2

Expert 100+
P: 534
And by the way, the code snippet for createdb command you posted is incorrect:
>> createdb -U dbname username
The correct format is
createdb -U username dbname
so make sure you call it correctly. Try "createdb --help" for more info.
Aug 18 '07 #3

P: 7
Thanks Michael.

You guessed it right.

I changed the line in pg_hba.conf file from

host all all md5
host all all trust

and the problem got solved.

Sorry for the mistake i made in createdb syntax.
My batch file syntax was right. I quoted wrong to the forum.

Once again, Thank you very much...
Aug 20 '07 #4

Expert 100+
P: 534
No problem, you're very welcome!
Aug 20 '07 #5

P: 1
I'm pleased to confirm that the solution of adding

set PGPASSWORD=my_password

to your .bat file works fine, too. Thanks for the tip!

~ Ken
Jan 13 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.