Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am using the following command for creating database in postgresql.

createdb -D pg_default -E UTF8 -h localhost -p 5432 -U pramil -W pramil mydb

but this command results prompt for password.When I enter password localhost server password, the following results

createdb:could not connect to database postgres:fe_senauth:no password supplied

Any one can hepl me?

share

migration rejected from stackoverflow.com Jun 20 '13 at 22:26

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as too localized by dezso, RolandoMySQLDBA, Mark Storey-Smith, Marian, Max Vernon Jun 20 '13 at 22:26

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

Please read the user manual section on client authentication.

You must ensure that you're using a user account that actually exists in PostgreSQL; the "localhost server password" is unlikely to be the password for your user account in PostgreSQL unless you set it up that way.

The message fe_sendauth: no password supplied suggests that you did not enter a password at all, just pressed enter. Your whole command line is way too complicated anyway; you're passing things that're defaults anyway, and you don't need to specify the port. More importantly, by passing -h localhost you're telling PostgreSQL to use a TCP/IP connection to localhost instead of the default unix socket connection. This has authentication implications.

On most typical installs on Linux distros (which I'm guessing is what you're using, since you didn't say) the postgres user account has ident authentication set up in pg_hba.conf for local (unix socket) connections. If this matches your setup you should be able to simply:

sudo -u postgres createdb -E UTF8 -O pramil mydb

This isn't specific to createdb, by the way; you're likely to have similar issues with psql and the other tools since they all use the same connection setup code.

share