I use postgresql command 'createuser myusername'. It prompts me for password always. If I leave password blank it gives an error that no password is specified.
I simply want to create a user with blank/no password and I'm not able to do it with Postgresql 9 under mac os x.
What steps should I take to create a user with no password. The command always asks me to enter a password.
You're barking up the wrong tree trying to fix this with
createuser
. If you care to check theman
page forcreateuser
it will tell you that login will fail if you really need a password and set --no-password.createuser
actually just creates a user. It does not decide how the user will have to authenticate.Authentication is handled mainly in
pg_hba.conf
, which decides whether or not to require passwords at login. I've never run PostgreSQL on OS X. On Linux, my distro's stock conf looks like this:I would make sure you have something like the first line for for development access. Note:
psql
will try to connect with a unix socket if there is no--host
option set. The second line would be used if you try to connect withpsql --host localhost
Rather than creating a user with no password, create a .pgpass file with the password in to have it automatically supplied. This will be respected by all applications that use libpq to connect, which is practically all of them except the JDBC driver and the .NET driver.
The additional way (I prefere it) to change user's password for PG user is to login to postgres console (as a
postgres
user on a local pc), and issue SQL request: