Postgres on Mac with Brew 💻

Brewing PostgreSQL on OS X

✋ This article is intended to save time while setting up the environment using Brew.

credit: wallpaperim.net
  • Install Brew:
$ /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Update brew
$ brew update
  • List Running Services
$ brew services list
mongodb-community stopped
postgresql stopped
  • Uninstall Existing Postgres (Only if you want) Remove the existing one if needed and not working.
$ brew uninstall --force postgresql
  • Remove the files on disk. Leftover manual remove
$ rm -rf /usr/local/var/postgres
  • Now, Install Postgres
$ brew install postgres
  • Time to start the Postgres running in the background.
$ brew services start postgresql

→ An alternative way to start:

$ pg_ctl -D /usr/local/var/postgres start
  • Create DB
$ initdb /usr/local/var/postgres

→ Delete a DB?

$ rm -r /usr/local/var/postgres
  • Create a User
$ /usr/local/Cellar/postgresql/X.X.X/bin/createuser -s postgres
  • Get the CLI
$ brew install postgis
  • Get inside:
$ psql DBNAME USERNAMEExample: pssql postgres gopi
  • Change the DB Password:
$ ALTER USER postgres WITH PASSWORD ‘postgres’;
  • Create DB, Role, Password at one shot:
$ createdb -h localhost -p 5432 -U postgres springbootdb password testme

Clients:

Download and install

pgadmin4 or DBeaver

PgAdmin can be opened at:

$ http://127.0.0.1:59163/browser/

Find the publication here: https://medium.com/thinkspecial

Gopi Krishna Kancharla- Founder of http://allibilli.com

--

--

--

Recommended from Medium

Cross-region and Cross account RDS MySQL DB replication: Implementation

Getting started with Bluetooth Low Energy connection in Android

鬼灭之刃剧场版:无限列车篇 完整版 ▷ Demon Slayer Mugen Train 完整版本 (2020 — “TW)

How I ended up with a mini home data center using raspberry pi

Work With SharePoint in Microsoft 365

How to remove .html from URL?

Multiple appsettings.json in .net core without using an environment variable

The official launch of Digihats on Ethereum! 🚀🚀🚀

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gopi Krishna Kancharla

Gopi Krishna Kancharla

Director of Software Engineering @ CapitalOne-Garage

More from Medium

Getting started with GitHub Actions

Migrating a PostgreSQL Database From Google Cloud to DigitalOcean

Serverless — Frontend

Nginx: Automatic Googlebot Whitelist