Search code examples
postgresqlosx-mountain-lion

OSX: How to change user password when account was created without one?


When I installed the PostgreSQL database server on my Mac, I created the "postgres" account so that it wouldn't have a password:

sudo dscl . -create /Users/postgres Password \*

I thought this would be a good security precaution to take. However, it also prevents me from logging in via the su command so that I can use psql to administer the database:

su - postgres    # <- prompts me for password

I've tried to change the postgres password using the "passwd" and "dscl . -passwd /Users/postgres" commands but they always prompt me for the old password. How do I set the password in this situation?

Thanks.


Solution

  • Use sudo su - postgres instead. Enter the sudo password, and you'll be postgres.