Linux Database Servers - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux Database Servers Guide
Complete beginner-friendly guide to database servers on Linux, covering Arch Linux, CachyOS, and other distributions including PostgreSQL, MySQL, MariaDB, MongoDB, and SQLite.
Table of Contents
PostgreSQL
Install PostgreSQL
Install PostgreSQL:
# Arch/CachyOS
sudo pacman -S postgresql
# Initialize database
sudo -u postgres initdb -D /var/lib/postgres/data
# Enable service
sudo systemctl enable --now postgresql.service
Debian/Ubuntu:
sudo apt install postgresql
Fedora:
sudo dnf install postgresql-server
PostgreSQL Configuration
Configure PostgreSQL:
# Edit config
sudo vim /var/lib/postgres/data/postgresql.conf
# Edit pg_hba.conf
sudo vim /var/lib/postgres/data/pg_hba.conf
MySQL/MariaDB
Install MariaDB
Install MariaDB:
# Arch/CachyOS
sudo pacman -S mariadb
# Initialize database
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
# Enable service
sudo systemctl enable --now mariadb.service
# Secure installation
sudo mysql_secure_installation
Debian/Ubuntu:
sudo apt install mariadb-server
Fedora:
sudo dnf install mariadb-server
MySQL Client
Use MySQL:
# Connect
mysql -u root -p
# Or MariaDB
mariadb -u root -p
MongoDB
Install MongoDB
Install MongoDB:
# Arch/CachyOS
yay -S mongodb-bin
# Enable service
sudo systemctl enable mongodb
sudo systemctl start mongodb
SQLite
Install SQLite
Install SQLite:
# Arch/CachyOS
sudo pacman -S sqlite
# Use SQLite
sqlite3 database.db
Database Tools
phpMyAdmin
Install phpMyAdmin:
# Arch/CachyOS
sudo pacman -S phpmyadmin
# Configure
sudo vim /etc/webapps/phpmyadmin/config.inc.php
Troubleshooting
Database Not Starting
Check logs:
# PostgreSQL
journalctl -u postgresql
# MariaDB
journalctl -u mariadb
Summary
This guide covered database servers for Arch Linux, CachyOS, and other distributions, including PostgreSQL, MySQL/MariaDB, MongoDB, and SQLite.
Next Steps
- Web Servers - Web server setup
- Development Environment - Development
- ArchWiki PostgreSQL: https://wiki.archlinux.org/title/PostgreSQL
- ArchWiki MariaDB: https://wiki.archlinux.org/title/MySQL
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.