Install DBMS on Raspberry Pi 5: Guide for Beginners

Author
01 Mar 2025

[ Requirements ]

  • Raspberry Pi 5 8GB
  • microSD Card or SSD
  • Adapter 5V/5A PD45W
  • Internet connection (Wi-Fi or Ethernet)
  • SSH enabled for remote access (optional)
  • Keyboard and monitor (optional, for direct setup)

 

1. Install Raspberry Pi 5 OS

Please refer to the documentation for installing Raspberry Pi 5. In this case, I will be connecting to my Raspberry Pi 5 via SSH on 'Raspberry Pi OS with desktop and recommended software (64-bit, Bookworm)'

1–1. Download Raspberry Pi OS Image

 

https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit

 

1–2. Install Raspberry Pi Imager

Install raspberry Pi Imager on your Desktop.

https://www.raspberrypi.com/software/

 

1–3. Write OS Image on SSD/SD Card using Pi Imager

Select “Raspberry Pi 5”

Select 'Use Custom'...

 

2. Set up Raspberry Pi 5

2–1. Configure General Properties

 

2–2. Configure SSH

2–3. Eject microSD card

Eject SD Card and Insert it to device slot, and boot...

 

3. Using MariaDB

3–1. Install MariaDB

$ sudo apt update
$ sudo apt install mariadb-server

3–2. Initial security configuration

Options include setting the root password, removing anonymous users, disabling remote root login, and deleting the test database.

$ sudo mysql_secure_installation

3–3. Connect to MariaDB

$ sudo mysql -u root

 

3–4. Allow Remote Access

You need to modify the MariaDB configuration file. Open the /etc/mysql/mariadb.conf.d/50-server.cnf file and either comment out the bind-address line or set it to 0.0.0.0.

3–5. Restart MariaDB

$ sudo systemctl restart mariadb

3–6. Configuring User for Remote Client Access

Access MariaDB database server with root privileges.

$ sudo mysql -u root -p

Create a new user and allow access from all IP addresses.

CREATE USER '{$USERNAME}'@'{$HOSTNAME}' IDENTIFIED BY '{$PASSWORD}';

Change the password for an existing user.

ALTER USER '{$USERNAME}'@'{$HOSTNAME}' IDENTIFIED BY '{$NEW_PASSWORD}';

Grant permissions on the database.

-- Allow whole database
GRANT ALL PRIVILEGES ON *.* TO '{$USERNAME}'@'{$HOSTNAME}';

-- Allow specific database
GRANT ALL PRIVILEGES ON {$DATABASE_NAME}.* TO '{$USERNAME}'@'{$HOSTNAME}';

Apply the changes.

FLUSH PRIVILEGES;

Check permissions.

SHOW GRANTS FOR '{$USERNAME}'@'{$HOSTNAME}';

If you are considering building a database on a Linux server for various purposes, I hope this guide proves helpful to you.

Happy hacking!

Buy Me A Coffee

Similar Posts