Install PostgreSQL on Gentoo Linux
Step 1 – Install
emerge --ask dev-db/postgresql
emerge --config dev-db/postgresql
rc-update add postgresql-14 default && rc-service postgresql-14 start
Step 2 – Connect as superuser
sudo -u postgres psql
Step 3 – Create database and user
CREATE USER appuser WITH PASSWORD 'StrongPass123!';
CREATE DATABASE appdb OWNER appuser;
GRANT ALL PRIVILEGES ON DATABASE appdb TO appuser;
\q
Key files
| File | Purpose |
|---|---|
/etc/postgresql-14/postgresql.conf |
Server settings |
/etc/postgresql-14/pg_hba.conf |
Client authentication |
Allow remote connections (optional)
/etc/postgresql-14/postgresql.conf: listen_addresses = '*'
/etc/postgresql-14/pg_hba.conf: host appdb appuser 0.0.0.0/0 scram-sha-256
systemctl reload postgresql 2>/dev/null || rc-service postgresql-14 reload 2>/dev/null || rcctl reload postgresql