For the complete documentation index, see llms.txt. This page is also available as Markdown.

How to install MariaDB

Hey there! So you need a database server on your Linux VPS? MariaDB is a great choice - it's fast, reliable, and fully compatible with MySQL. Let's get it installed and set up properly.

Step 1: Update Your System

Always start with updated packages:

# For Ubuntu/Debian
sudo apt update && sudo apt upgrade -y

# For CentOS/RHEL
sudo yum update -y

Step 2: Install MariaDB

Ubuntu/Debian:

sudo apt install mariadb-server mariadb-client -y

CentOS/RHEL 8+:

sudo dnf install mariadb-server mariadb -y

CentOS/RHEL 7:

sudo yum install mariadb-server mariadb -y

Step 3: Start and Enable MariaDB

You should see "active (running)" in green.

Step 4: Secure Your Installation

This is important! Run the security script:

You'll be asked:

  1. Enter current password for root: Press Enter (no password yet)

  2. Set root password? Type Y and choose a strong password

  3. Remove anonymous users? Type Y

  4. Disallow root login remotely? Type Y (for security)

  5. Remove test database? Type Y

  6. Reload privilege tables? Type Y

Step 5: Basic Configuration

Edit MariaDB Config:

Add these under [mysqld] section:

Restart to apply changes:

Step 6: Create a Database and User

For security, create separate users for each application:

Step 7: Test Your Setup

Step 8: Backup Your Database

Always have backups! Create a simple backup script:

Add:

Make it executable:

Common Issues & Solutions

"Can't connect to MariaDB"

"Access denied for user"

Reset password if forgotten:

Useful Commands

Check MariaDB Version:

Show Running Processes:

Check Database Size:

That's it! Your MariaDB server is ready. Remember to regularly update and backup! ๐Ÿš€

Last updated