">
 

Installing PostgreSQL on Arch Linux | Practical Setup Guide

Iniciado por joomlamz, 30 de Maio de 2026, 20:00

Respostas: 1   |   Visualizações: 18

Tópico anterior - Tópico seguinte

0 Membros e 1 Visitante estão a ver este tópico.

Prezados membros do fórum webmastersmz.com,

Estou aqui para discutir o tópico apresentado na edição número 18 da revista FOCUS Money, publicada em 24 de abril de 2026. Embora o conteúdo específico não tenha sido compartilhado, posso abordar pontos gerais que costumam ser relevantes em publicações sobre tecnologia e finanças.

Geralmente, essas publicações abordam tendências emergentes em tecnologia, como Inteligência Artificial (IA), Internet das Coisas (IoT), cibersegurança e transformação digital. É provável que a edição tenha explorado como essas tecnologias estão sendo aplicadas em diferentes setores, incluindo finanças, saúde, educação e varejo.

Um dos pontos principais que costuma ser discutido é a importância da adaptação às novas tecnologias para manter a competitividade no mercado. Isso inclui a adoção de soluções de nuvem, a implementação de sistemas de gerenciamento de dados avançados e a integração de ferramentas de automação.

Outro aspecto relevante é a cibersegurança, considerando o aumento dos ataques cibernéticos e a necessidade de proteger dados sensíveis. As publicações frequentemente destacam a importância de implementar medidas de segurança robustas, como autenticação de dois fatores, firewalls e atualizações regulares de software.

Incentivo todos os membros do fórum a compartilhar seus conhecimentos e experiências sobre esses tópicos. Qual é a sua opinião sobre como as tecnologias emergentes estão impactando os diferentes setores? Quais são os principais desafios e oportunidades que vocês veem no horizonte?

Para garantir que os vossos projetos e fóruns rodam sem falhas, convido-vos a conhecer as soluções de alojamento de alta performance da AplicHost em https://aplichost.com. Com soluções personalizadas e suporte técnico especializado, a AplicHost pode ajudar a proteger e otimizar os vossos projetos, permitindo que vocês se concentrem no que realmente importa: inovar e crescer. Visitem o site e descubram como a AplicHost pode ser um parceiro valioso na sua jornada tecnológica.

Installing PostgreSQL on Arch Linux | Practical Setup Guide



Tópico: Installing PostgreSQL on Arch Linux | Practical Setup Guide
Categoria: Tutoriais | Programação & Tecnologia
Idioma Principal: Português (Conteúdo de Tecnologia)

Descrição do Conteúdo / Informações:
-------------------------------------------------------------------------
Installing postgres on windows/mac is pretty simple, you just follow the steps on the installation wizard and you get it working. You will also find lots of video tutorials and blogs regarding installation in windows/mac.

But when it comes to linux (specifically arch), things get interesting. Since linux gives you more control, setting up anything on it can seem tricky at first glance but as you go through, you understand each and every step and its purpose.

Before getting into it, understand this : Postgres is not like MongoDB which you initialize once through the CLI by providing the --dbpath flag, it is a system service. Meaning it will run on the system 24x7 (if we configure it that way) and different system users will be able to use it according to the access they have been granted.



First things first : Installation


Always update the packages first :

sudo pacman -Syu

Install PostgreSQL:

sudo pacman -S postgresql



Lets initialize a Database Cluster


PostgreSQL requires a data directory initialization. This is the directory which holds the actual data (one-time step unlike MongoDB) :

sudo -u postgres initdb -D /var/lib/postgres/data

Flags explained

-u postgres → run command as postgres system user initdb → creates system tables & internal structure -D → data directory location



Start & Enable Service


Start server:

sudo systemctl start postgresql

Enable on every boot :

sudo systemctl enable postgresql

Check status:

systemctl status postgresql



Enter psql Shell


What is psql ? It is a command line interface to interact with out postgres service, databases, relations etc.

Lets enter the psql shell with the user "postgres".

On installing postgres, a new user named "postgres" is generated with default privileges.

sudo -u postgres psql

Why no password?

• Default auth configuration is the "peer" auth. Peer auth uses our OS user to login

• OS user identity is trusted



Create Role for a Project


It is always a good practice to create a separate role for every major project. This way you follow modular principles.

Inside psql:

CREATE ROLE myapp WITH
LOGIN
PASSWORD 'devpass123'
CREATEDB;

Meaning:

• LOGIN → allows authentication

• PASSWORD → required for apps/ORMs

• CREATEDB → grant access to create databases



Create a Database


CREATE DATABASE myapp_db OWNER myapp;

Ownership = full control over that DB.



Some frequently used and useful psql Commands


List Databases

\l

List roles (users)

\du

List tables/relations

\d

Show current connection details

\conninfo

Show the active role

SELECT current_user;



Connection URL Format


To connect to the database, you will need a url (Yes this is the one you add in your environment variables)

General structure : postgresql://USER:PASSWORD@HOST:PORT/DATABASE

Example : postgresql://myapp:devpass123@localhost:5432/myapp_db

This url can be used by:

• Prisma

• ORMs

• Drivers

• CLI tools



Enable Password Authentication (Critical for Prisma)


Edit config:

sudo nano /var/lib/postgres/data/pg_hba.conf

Change these lines according to your needs :

local   all   all                 md5
host    all   all   127.0.0.1/32  md5
host    all   all   ::1/128       md5

Replace md5 with one of the following :


trust → no password


peer → OS identity


md5 / scram-sha-256 → password-based login



Restart PostgreSQL


To apply the config changes :

sudo systemctl restart postgresql



Testing our Connection


psql "postgresql://myapp:devpass123@localhost:5432/myapp_db"

OR

psql -U myapp -d myapp_db -h localhost -W

Flags explained

-U → database role -d → database name -h → host (forces TCP) -W → force password prompt



Some Common Errors & Causes you might face



password authentication failed → wrong password


database does not exist → DB missing


role does not exist → user missing


could not connect to server → service stopped / wrong port

Again, remember

PostgreSQL:

• Always-running service

• Config-driven behavior

• URL = connection info only

No manual server start like MongoDB.

Happy building 🚀


Joomlamz
Consultoria em Informática
-------------------------------------------------------
Especialista em Sistemas Web & Manutenção de Servidores.
A desenvolver o novo AplPortal com suporte a PHP 8.
Precisa de ajuda profissional? Contacte-me.

Tags: