Ozan Kahramanogullari <ozan.kah@gmail.com> writes:
> I get these:
> XXX:~ ozan$ nslookup localhost
> Server: 192.168.206.99
> Address: 192.168.206.99#53
> Name: localhost.unitn.it
> Address: 10.31.101.168
Well, *that's* screwed up. You should complain to your local network
manager about it. "localhost" ought to resolve to 127.0.0.1,
or ::1/128 in IPv6-land, not something else. It's possible that
10.31.101.168 is your Mac's address, but that still doesn't make this
correct behavior. So for the moment, don't use "-h localhost".
> I first try this:
> XXX:~ ozan$ psql -h 127.0.0.1
> psql: FATAL: database "ozan" does not exist
Check ...
> XXX:~ ozan$ psql -U postgres
> psql (10.5)
> Type "help" for help.
> postgres=# CREATE USER ozan WITH PASSWORD 'parrot';
> ERROR: role "ozan" already exists
> postgres=# CREATE DATABASE lecture;
> ERROR: database "lecture" already exists
> postgres=# GRANT ALL PRIVILEGES ON DATABASE lecture to ozan;
> GRANT
That's all fine, but you didn't create a database named "ozan",
so it's unsurprising that you get this:
> XXX:~ ozan$ psql -h 127.0.0.1
> psql: FATAL: database "ozan" does not exist
If you want the connection to go to the database named "lecture",
you need to say "psql lecture", or some more verbose form of that
such as "psql -h 127.0.0.1 -U ozan lecture". When you don't mention
a database on the command line, psql's default behavior is to try
to connect to a database named the same as the user.
regards, tom lane