Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm completely helpless, maybe you guys can help me out. I installed PostgreSQL under my new MacOSX Lion. When I try to connect to my localhost with pgAdminIII.app it says:

Error connecting to the database: FATAL password authentication failed for user postgres  

I just have no idea what to do? Non of my passwords work. Neither my adminpass nor "postgres" nor anyhting else.

I tried to install it again via the console where I found this helpful link: http://www.peerassembly.com/2011/08/...resql-on-lion/ However the problem is, that when I try to run createuser -a -d _postgres the same password problem appears again. I just can't seem to find a solution to this. Always wrong password.

Btw. I have a new User called "PostgreSQL" on my machine after I installed postgres.

Any ideas? I'm so stuck and I really need to make this work.

share|improve this question
add comment

2 Answers 2

Easiest solution is to tell postgres to just let you in. Locate your pg_hba.conf. Location of this file depends how you installed it is but it is in the data directory of your postgresql install. Execute the following command in a terminal to let the computer locate it for you.

sudo find / -name pg_hba.conf

(sudo is needed because it might be in a folder you do not have access to as a normal user)

There is a lot of comments in this file to explain how it works. What you want todo is to set the authentication method for local and/or 127.0.0.1 connections to trust. When you have done this postgresql will no longer verify your password (thought pgAdmin still tends to ask for it just enter something). When you are in pgadmin you can change the password. Then you change the method in pg_hba.conf back to md5 to secure things.

How did you install PostgreSQL? Personally I find the one click installer very easy.

edit: response to comments

PostgreSQl has it's own internal list of usernames. These names have nothing todo with the OSX usernames. The OSX username PostgreSQL is used to run postgresql's postmaster process with limited access to the system. postgres is the database superuser name created by the one click installer.

The server doesn't listen message is a bit weird because password validation happens only after a connection is established so I would have expected you to get this error earlier to. Maybe you changed something? Anyway I suspect from the error message that pgAdmin is trying to connect to localhost which is resolved to ::1 (ipv6 address) but AFAIK postgresql only listens on ipv4 with the one click installer. When you right click on the Postgresql entry in pgAdmin and select properties you can change the host pgAdmin connects to. Change it to 127.0.0.1 and try again.

share|improve this answer
    
Thank you. I found pg_hba.conf with your method in /Library/PostgreSQL/9.1/data/pg_hba.conf. I changed the values to trust. When I try to use pgAdminIII.app and doubleclick on the localhost server I'm now one step further. Still doesn't work, but it doesn't say that the pass is incorrect. Instead it says: Server doesn't listen The server doesn't accept connections: the connection library reports - could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? –  Matt Oct 15 '11 at 16:58
    
Some additional info: I installed it with the one click installer and the installation process did not throw any errors. However I always had this problem with the password. It always said: password fail for user postgres Do I actually need this postgres user? Because when I'm in my loginscreen on my mac I had a seperate user called PostgreSQL. It didn't work with this user either, but now I completely deleted it. Do I need this user in order to have postgre working? –  Matt Oct 15 '11 at 17:02
    
When I list all my users on my computer with sudo dscl . -list /Users UniqueID I do have a _postgres User. If I do dscl . read /users/_postgres I get this … AppleMetaNodeLocation: /Local/Default GeneratedUID: FFFFEEEE-DDDD-CCCC-BBBB-AAAA000000D8 NFSHomeDirectory: /var/empty Password: * PrimaryGroupID: 216 RealName: PostgreSQL Server RecordName: _postgres RecordType: dsRecTypeStandard:Users UniqueID: 216 UserShell: /usr/bin/false –  Matt Oct 15 '11 at 17:28
    
@Matt: response to your comments in my answer. They are a bit long for a comment. –  Eelke Oct 16 '11 at 6:26
add comment
set pg_hba.conf

Where pg_hba.conf is in $PG_DATA. For example, mine is /Source/local/pgsql91/data.

host    all             postgres        127.0.01/32            trust

Then

/usr/pgsql-9.1/bin/psql -U postgres -d postgres -h 127.0.0.1

Otherwise (without -h) psql bounces you to you network ip (ifconfig) Eg for me 192.168.0.1 which is md5 and psql is in clear by default.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.