Urgent.News

What's breaking now, across thousands of outlets.

Tech

Installing and setting up Postgres in Ubuntu

At work, we handle a lot of short-term projects, typically lasting 3-8 weeks. These projects don't require a complex deployment setup. Instead, we deploy each project on a single VPS instance, with all the stacks bundled together on the same system. Sure, it's a single point of failure and not the ideal setup, it however matches our clients’ budget and allows us to deliver quickly. Luckily, we've…

Installing and setting up PostgreSQL in Ubuntu involves a few key steps. First, the PostgreSQL package along with its contrib modules can be installed using the command `sudo apt install postgres postgresql-contrib`. After installation, PostgreSQL runs as a service managed by systemd. To initiate the service, the command `sudo systemctl start postgres.service` is used. To ensure it starts automatically after a reboot, `sudo systemctl enable postgres.service` is executed.

Next, to establish access to the database, a new user must be created. Initially, a default `postgres` user is generated with administrative privileges. To create a new user, one needs to switch to the `postgres` user with `sudo su postgres`. Following this, the `createuser` command can be run interactively to set the username and decide if the role will have superuser privileges.

Creating a database is straightforward; it can be done using the `createdb` command followed by the desired database name. However, the new user needs permissions to interact with the database. This is achieved by logging into PostgreSQL with `psql` and executing SQL queries to grant specific rights, such as `GRANT CONNECT ON DATABASE {{database_name}} TO {{username}};`, `GRANT pg_read_all_data TO {{username}};`, and `GRANT pg_write_all_data TO {{username}};`.

Finally, to authenticate with the created user, their password must be set. As the `postgres` user, who has the highest authority, this is accomplished using the command `ALTER USER {{username}} WITH PASSWORD {{new_password}};`. After setting the password, exiting both the SQL shell (`\q`) and the `postgres` user shell is required.

While alternative methods like Docker images or Ansible scripts can simplify setup, especially for large-scale deployments, this manual approach allows for tailored configurations suited to specific needs.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Hello, world!

Finally! My personal blog pings the world of the internet with a hearty "Hello, world!" It honestly took me a while to buckle down and do it, but after a bunch of pins on Pinterest and checking out…

  • Author created personal blog with "Hello, world!" message
  • Chose NuxtJS and VueJS for frontend development
  • Deployed site on Digital Ocean VPS with Cloudflare security

Getting the Function Keys Back on a Realme Book i5

A few years ago, I bought a Realme Book i5 for work. I bought it because it was slim, the display was nice, and it was a great lightweight machine to work on away from my desk.

  • F1-F12 keys defaulted to media keys on Realme Book i5
  • FNSP=0, FNRV=1, MFNM=0 activated standard F-key mode
  • Custom device modified EC fields during boot for F-key functionality

Getting into the world of Ansible

Getting into the world of Ansible Ever since I started exploring DevOps, I’ve always loved the idea of automating server setups with a single script.

  • Ansible, automation tool, manages server setups
  • AI tools lower entry barrier for Ansible
  • Migrated Uptime Kuma app using Ansible

New Portfolio in the Works

New Portfolio in the Works. I’ve always wanted a cool, chibi-style profile picture for my portfolio, but I've never been good at drawing.

  • Designer created portfolio with Ghibli-style image generator.
  • Inspired by modern techy design, aiming for warmer aesthetic.
  • Focused on legibility and responsiveness across devices.

No measurement, no optimization

No measurement, no optimization. There's a common saying in programming: "Don't optimize what you haven't measured yet." You can only truly appreciate this advice when you experience it yourself.

  • Optimization should follow performance measurement
  • Database queries caused most performance issues
  • Combined queries had higher average response time

More from Sunday 27 September →