Install Postgres locally in MacOS

Install using Brew package manager


Andres Canavesi
Aug 18, 2020
How to install Postgres database in your MacOS local machine
featured image

Install using Brew package manager

      
brew update
brew install postgres
   
    

Config file

      
/usr/local/var/postgres/postgresql.conf 
   
    

Useful commands

      
brew services start postgresql
brew services restart postgresql
brew services stop postgresql
   
    

psql command

"psql is a terminal-based front-end to PostgreSQL. It enables you to type in queries interactively, issue them to PostgreSQL, and see the query results."

Run psql and you will see the following error
      
$ psql
psql: error: could not connect to server: FATAL:  database "andrescanavesi" does not exist
   
    
So let's create a db with that name in order to play with it
      
createdb andrescanavesi
   
    
List available databases
      
\l
      
    
Use a specific database
      
\c andrescanavesi 
   
    
List tables
      
\dt
   
    
See your version
      
SELECT version();
   
    

Resources

  • https://www.datacamp.com/community/tutorials/10-command-line-utilities-postgresql
  • https://gist.github.com/ibraheem4/ce5ccd3e4d7a65589ce84f2a3b7c23a3

Recommended posts