DEV Community

Cover image for PostgreSQL setup via homebrew for junior devs
vatana7
vatana7

Posted on

1

PostgreSQL setup via homebrew for junior devs

Introduction

No need to stress it out if you are trying to set up PostgreSQL on your machine. Just simply follow this guide, you'll be ready in no time.

This guide assumed that you have homebrew installed already in your terminal. So if you don't please install it and come back to this guide.

Getting PostgreSQL

Run brew install PostgreSQL then wait for it to finish.

Make sure that you restart your terminal

Running PostgreSQL in background

Run brew services start PostgreSQL to start PostgreSQL service.
You only have to run this once because now PostgreSQL will boot up every time you turn on your laptop.

Create a database and a superuser

  • To create database, run createdb dbname.
  • To create a superuser, run createuser -s postgres. Here -s flag indicate that we're create a superuser. postgres is the name that we're giving to the user.

Accessing PostgreSQL

Run psql -U postgres in your terminal to interact with PostgreSQL. Here -U postgres indicate that we're interacting as User with the name postgres that we have just created with superuser role.

Start interacting with PostgreSQL

Run \l to list all database or \du to list all users. To quit PostgreSQL interactive mode simly run \q.

Image description

That's it folks, thank you for reading my post!

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay