Skip to content

Instantly share code, notes, and snippets.

@liron-navon
Forked from pauloremoli/create_user_postgres.md
Last active November 28, 2024 13:46
Show Gist options
  • Select an option

  • Save liron-navon/53726695d04085f4bda702581dcce418 to your computer and use it in GitHub Desktop.

Select an option

Save liron-navon/53726695d04085f4bda702581dcce418 to your computer and use it in GitHub Desktop.
Create postgresql user Mac OS X

Installing postgresql on Mac OS X

$ brew install postgresql@16 $ brew services start postgresql@16

If you fail to ping postgreql, do these steps:

  1. Stop PostgreSQL

brew services stop postgresql@16

  1. Delete the postmaster.pid

rm -f /opt/homebrew/var/postgresql@16/postmaster.pid

  1. Start the PostgreSQL again

brew services start postgresql@16

Create postgresql user Mac OS X with password

After installing the postgres app: http://postgresapp.com/

It will create a database user with the current username, to create another user for example 'postgres':

$ createuser postgres -s

Open psql with the created user using -U

$ psql postgres -U postgres

Change the password

$ ALTER USER postgres WITH PASSWORD 'postgres';

Create an empty database - most migrations need this step

$ su - postgres $ createdb testdb

Access shell

$ psql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment