Postgres installation in Mac
First, we need HomeBrew. HomeBrew is a free and open-source package manager that simplifies installation of software in Apple MacOS.
To install homebrew, paste the following command in terminal
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install Postgres
Postgres is an object-relational database management system (ORDBMS).
brew install postgres
Start Postgres
Immediately after the installation of Postgres above, you will get the required steps for you to take. Generally, this is to start Postgres
To run Postgres in the background, then
brew services start postgresql
To run Postgres without background services, I mostly prefer this, then
pg_ctl -D /usr/local/var/postgres start
Configuring Postgres
To start interacting with your database, run this command
psql postgres
From here now, you can do any administrative tasks with your databases.
\l
— to view all databases
create database databasename
— creates a new database
\dt
— to view tables in a table
and many more commands.
Check out this cheatsheet on Postgres commands.