Installing MariaDB on Raspberry Pi using Docker

MariaDB is a database management system that is a fork of MySQL, primarily maintained by the open-source community and licensed under GPL. The goal of MariaDB is to be fully compatible with MySQL, including the API and command line, making it an easy replacement for MySQL.

Installation Steps

1. Search for the MariaDB image (ensure Docker and Docker Compose are installed)

docker search mariadb

Installing MariaDB on Raspberry Pi using Docker

2. Download the image (generally download the one with the most STARS)

docker pull mariadb

Installing MariaDB on Raspberry Pi using Docker

3. View the images

docker images

Installing MariaDB on Raspberry Pi using Docker

4. Create a directory for mapping with the container

mkdir /home/pi/mariadb/{log,conf,data} -p

Installing MariaDB on Raspberry Pi using Docker

5. Start the MariaDB instance

Set MYSQL_ROOT_PASSWORD, the password for the root user of the database to “raspberry”.

docker run -id --name mariadb_test 
-v /home/pi/mariadb/conf:/etc/mysql/conf.d 
-v /home/pi/mariadb/logs:/var/log/mysql 
-v /home/pi/mariadb/data:/var/lib/mysql 
-e TZ=Asia/Shanghai 
-e MYSQL_ROOT_PASSWORD=raspberry 
-p 3306:3306 mariadb

Installing MariaDB on Raspberry Pi using Docker

6. View the running containers

docker ps -a

Installing MariaDB on Raspberry Pi using Docker

7. Access the container and log in to the database

docker exec -it mariadb_test /bin/bash
root@060476e080a8:/# mariadb -u root -pEnter password:

Installing MariaDB on Raspberry Pi using Docker

Leave a Comment

×