vatana7
Posted on March 27, 2024
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
.
That's it folks, thank you for reading my post!
Posted on March 27, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.