Mac OS X: role “postgres” does not exist

  1. Install Postgres

    brew install Postgres
    
  2. Try to log in.

    $ psql -h localhost -d postgres -U postgres  
    psql: error: could not connect to server: 
    FATAL:  role "postgres" does not exist
    
  3. Create the user

     $ /usr/local/opt/postgres/bin/createuser -s postgres 
    
  4. Start the server

    $ pg_ctl -D /usr/local/var/postgres start 
    pg_ctl: another server might be running; trying to start server anyway
    waiting for server to start....2020-06-27 18:12:07.784 +08 [20812]
     FATAL:  lock file "postmaster.pid" already exists
    2020-06-27 18:12:07.784 +08 [20812] HINT:  Is another postmaster (PID 4901)
     running in data directory "/usr/local/var/postgres"?
     stopped waiting
    pg_ctl: could not start server
    Examine the log output.
    

It just works!!

$ psql -h localhost -d postgres -U postgres
psql (12.3)
Type "help" for help.

postgres=#

References

Written with StackEdit.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.