I'm trying to create a new Postgres database and superuser, on Debian 7.
However, I don't seem to be able to connect to my new database once I've created it.
This is what I've done:
$ sudo su - postgres
postgres@:~$ createdb prescribing
postgres@$ psql
postgres=# create user prescribing with password 'mypassword';
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE prescribing to prescribing;
GRANT
postgres=# exit\q
could not save history to file "/var/lib/postgresql/.psql_history": No such file or directory
postgres@:~$ psql -d prescribing -U prescribing
psql: FATAL: Peer authentication failed for user "prescribing"
What have I done wrong?
I'm not sure whether the error is to do with the lack of a history file, or whether it's some interaction between Unix user and database user that I don't fully understand.
I also tried psql -U prescribing -d prescribing -W, to see if I could get it to ask me for a password, but it didn't help.
Update: Here's the content of pg_hba.conf:
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5