Re: psql on Mac

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ozan Kahramanogullari <ozan(dot)kah(at)gmail(dot)com>
Cc: Andrej Ricnik <andrej(dot)groups(at)gmail(dot)com>, Jeff Frost <jeff(dot)frost(at)gmail(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: psql on Mac
Date: 2018-10-24 13:01:16
Message-ID: 19578.1540386076@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-novice

Ozan Kahramanogullari <ozan(dot)kah(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Ozan Kahramanogullari 2018-10-24 13:15:15 Re: psql on Mac
Previous Message PG Bug reporting form 2018-10-24 12:26:53 BUG #15456: Trigger function using ROW(NEW.*) has wrong columns if table is modified during a session

Browse pgsql-novice by date

  From Date Subject
Next Message Ozan Kahramanogullari 2018-10-24 13:15:15 Re: psql on Mac
Previous Message Ozan Kahramanogullari 2018-10-24 12:02:14 Re: psql on Mac