PostgreSQL

PostgreSQL is a powerful, open source object-relational database system with over 35 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.

Installation

Brew installation

brew install postgresql

Download page -

Usage

Starting service

brew services start postgresql@15

Stopping service

brew services stop postgresql@15

Configure the Postgres Database Server

Once the postgres server is up and running, the next step is to configure it for use.

We are going to create a root user that will have administrator privileges to the database server. Make sure that the service is running and then run the following command.

psql postgres

Note: if you get psql: command not found Mac

User actions

Add the following to .zshrc export PATH=/usr/local/opt/postgresql@15/bin:$PATH

We are going to create a new user that will have the privileges to create and manage databases within the service.

You can execute the command as follows to create the new user with the right access.

Create

CREATE ROLE newUser WITH LOGIN PASSWORD 'password';
ALTER ROLE newUser CREATEDB;

Once the new user is created, you can also start using the credentials and log in with the new user’s credentials.

You can use the following command to log in with the new user’s credentials.

First, we need to quit the current session

\q - quits current session

and then reconnect with the new user’s credentials.

psql postgres -U newuser

Using PGAdmin

Download link

Create a new server with the following

  • name – “Postgresql 15”
  • host – “localhost
  • user – “newuser
  • password – “password
  • maintenance database – “postgres
  • Create a DB

    Back to all articles