Note: If you have not installed cardano-db-sync
, then you should skip this guide and continue to next guide: 3. Run scripts
This document explains how to install PostgreSQL and create a Postgres user.
-
This guide assumes you are running a recent version of linux.
Specifically, these directions apply to Ubuntu (Debian). If you are using a different linux variant, please adjust as needed
-
Update/upgrade your package indexes
sudo apt-get update sudo apt-get upgrade # reboot as necessary
-
Install postgreSQL packages
sudo apt-get install postgresql postgresql-contrib
-
Verify postgres is installed by starting a postgres sql session in the terminal
sudo -u postgres psql # you should see prompt # postgres=# # to exit the session \q
-
Upon installation, Postgres is set up to use
ident authentication
,meaning that it associates Postgres roles with a matching Unix/Linux system account.
If a role exists within Postgres, a Unix/Linux username with the same name is able to sign in as that role.
- Additional background documentation: Postgresql Ident Authentication
-
Create a user for your local linux user account and give it superuser role. Our user must be a superuser in order to create/drop databases, etc.
sudo -u postgres createuser --interactive # enter your linux user account Enter name of role to add: <your_linux_user_account_name> Shall the new role be a superuser? (y/n) y
-
Verify your local account got created
sudo -u postgres psql # you should see prompt # postgres=# # to display users \du # you should see a role name of your linux account with Superuser role attribute # to exit the session \q
Continue to next guide: 3. Run scripts