17

I got my new lion machine. Ran the PostgreSQL installer from the PostgreSQL site for Mac and i have no multiple apps installed. One of them is "pgAdmin III.app". When I open it there is already one server connection available. localhost:5432

Whenever I try to connect to the server with a doubleclick the programm asks me for a password. I have no idea what to enter. It's not my admin password, it's not "postgres", it's not "localhost", it's not empty.

I just can't seem to connect to the server. Even when I check the properties of the localhost server the password field seems empty. However I'm not allowed to leave the password field empty.

Any idea what to do? I really need to setup postgres?

matt
  • 37,699
  • 99
  • 250
  • 390

4 Answers4

9

On my Mac OSX Lion, PostgreSQL configuration files are stored under /Library/PostgreSQL/9.0/data/

ssc
  • 8,576
  • 8
  • 51
  • 84
4

Haven't tried it on OSX, but on Ubuntu you can login as the system user 'postgres' to the default database 'postgres' without a password with

su postgres -c psql

You can then (re)set the password of the database superuser 'postgres'.

You can also edit the configuration file pg_hba.conf (don't know where it is located on a default OSX installation, on Ubuntu it is /etc/postgresql/8.4/main/pg_hba.conf) and grant access to the default database without authentication

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
host    postgres    postgres    127.0.0.1/32          trust

After editing pg_hba.conf you must reload the configuration with

pg_ctlcluster 8.4 main reload

You can then connect with pgAdmin and (re)set the password, but don't forget to change the authentication method back to md5 again...

James Kingsbery
  • 6,839
  • 2
  • 37
  • 65
tscho
  • 1,926
  • 12
  • 15
  • 5
    The problem is that I can't find the pg_hba.conf file. it's not in `/private/var/` since there is not even a `pgsql` directory. When I try to run `su postgres -c psql` and enter my computer passphrase the console says "Sorry" – matt Oct 13 '11 at 20:16
  • I found quite a lot of links regarding this issue, however no one has this password problem. Most of the described problems are a failed installation. http://od-eon.com/blogs/calvin/os-x-lion-postgresql/ E.g. I found this - http://xiphone.org/how-to-install-postgresql-on-os-x-lion/ - it says `/usr/local/pgsql/` I do not even have this pgsql directory in `/usr/local`Any idea why? – matt Oct 13 '11 at 20:19
  • Sorry, I have no experience with PostgreSQL on OSX at all, so I don't know where the PostgreSQL folders and files *should* be located after a successful installation. But `su postgres -c psql` as root should definitely work with a default configuration. – tscho Oct 13 '11 at 21:31
  • @tscho, the `psql` command doesn't run on OSX (HighSierra) so these instructions cannot be followed – ekkis Nov 30 '18 at 23:39
2

here's a better answer (works in OSX HighSierra): the account used is the one you're logged onto OSX with, therefore, the password is your password!

ekkis
  • 8,231
  • 11
  • 44
  • 85
0

A similar question has been asked a short time ago. The steps described there should be appropriate for Lion also.

Postgresql: password authentication failed for user "postgres"

Community
  • 1
  • 1
A.H.
  • 57,703
  • 14
  • 82
  • 113
  • 1
    Thank you but I can't seem to find `pg_hba.conf` I have no idea where this file is located on a mac. I just found a lot of _conf.sample files inside /usr/share but no `pg_hba.conf` file. Any idea where this file could be? – matt Oct 13 '11 at 19:41
  • 1
    You could try the command `locate pg_hba.conf`. A quick google brought up `/private/var/pgsql/pg_hba.conf`. Since I'm not on Lion, _I_ cann't look :-) – A.H. Oct 13 '11 at 19:47
  • @A.H. you sir are a life saver! I didn't have a `pg_hba.conf` all I had was a sample file of it – Bankzilla Apr 30 '13 at 22:09
  • `locate pg_hba.conf` (on OSX HighSierra) comes up empty. suggestions? – ekkis Nov 30 '18 at 23:37