03 - Banco de Dados (PostgreSQL)

1️⃣ Iniciar PostgreSQL

sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo systemctl status postgresql

Você pode ver se esta rodando assim tambem

ls /etc/postgresql/ saida do terminal mostrando a versão exemplo: 16

sudo systemctl status postgresql@16-main

Você deve ver: active (running)


2️⃣ Criar Usuário e Banco

sudo -u postgres psql << 'EOF'
CREATE USER twinslkit_user WITH PASSWORD 'SUA_SENHA_FORTE_AQUI';
CREATE DATABASE twinslkit OWNER twinslkit_user;
GRANT ALL PRIVILEGES ON DATABASE twinslkit TO twinslkit_user;
\q
EOF

⚠️ Troque SUA_SENHA_FORTE_AQUI por uma senha segura (mínimo 16 caracteres, use letras, números e símbolos).


3️⃣ Testar Conexão

psql -U twinslkit_user -h localhost -d twinslkit

Digite a senha que você criou.

Se aparecer o prompt twinslkit=>, está funcionando!

Para sair:

\q

Próximo passo: 04-aplicacao-nextjs