Databáze řešení

Getting Started with Databases (PostgreSQL on Ubuntu)

A database stores your application’s data. PostgreSQL is a powerful, open-source relational database. This guide installs it and creates your first database and user.

1. Install PostgreSQL

sudo apt update
sudo apt install -y postgresql postgresql-contrib

2. Verify the service

sudo systemctl enable --now postgresql
sudo systemctl status postgresql

3. Create a database and user

sudo -u postgres psql

CREATE DATABASE myapp;
CREATE USER myuser WITH ENCRYPTED PASSWORD 'strong_password';
GRANT ALL PRIVILEGES ON DATABASE myapp TO myuser;
\q

4. Connect to your database

psql -h localhost -U myuser -d myapp

Relational databases (PostgreSQL, MySQL) use tables and SQL; NoSQL databases (MongoDB, Redis) store documents or key-value pairs. Choose based on your data structure and query needs.

Byla tato odpověď nápomocná?

0 Uživatelům pomohlo

Powered by WHMCompleteSolution