Skip to content

Instantly share code, notes, and snippets.

@1st
Last active October 16, 2019 13:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1st/99a6dbea23c6335d3cec to your computer and use it in GitHub Desktop.
Save 1st/99a6dbea23c6335d3cec to your computer and use it in GitHub Desktop.
HowTo setup Postgres on macOS
# 0. install a Postgres
# we use HomeBrew for this
brew install postgres
# init file structure for all databases
initdb /usr/local/var/postgres
# 1. create new user for a database
# 1.1. user without password
createuser username
# 1.2. user with password
createuser --pwprompt username
# 2. create new database
# specify user that will access this database (created above)
createdb -O username dbname
# 3. test connection
# 3.1. user without password
psql -U username dbname
# 3.2. user with password
psql -U username -W dbname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment