Database
Most of our SaaS environments have a database. It’s useful to have a graphical view on them to investigate issues.
Connecting
If you’re connecting to a SQL database hosted in a cloud, you most probably need to whitelist your IP, or (in case of Google), install and use a proxy to connect through a Unix socket as documented at gcloud.
PostgreSQL
PostgreSQL is our database of choice.
There’s always a version of pg available in Ubuntu, but in case you need a specific version, chances are, you’re better off installing the PostgreSQL PPA.
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /usr/share/keyrings/postgresql.gpgecho "deb [signed-by=/usr/share/keyrings/postgresql.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.listsudo apt update
You probably run the server in a docker compose setup anyway.
When importing and exporting database dumps, the version of psql
used matters.
So it’s common you need multiple versions of the tool on your system.
sudo apt install postgresql-client-16 postgresql-client-17/usr/lib/postgresql/16/bin/psql --version/usr/lib/postgresql/17/bin/psql --version
PGAdmin4
PGAdmin4 can be used to connect to PostgresSQL databases.
pgadmin
can be installed as:
sudo curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key addsudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'sudo apt install pgadmin4-desktop