MariaDB
MariaDB is a popular open-source database server. It is a drop-in replacement for MySQL. This guide will walk you through how to use MariaDB with Spin.
Installation
To install MariaDB, you will be prompted to include the MariaDB service on install. You simply just need to select it.
What Spin does for you
When you install MariaDB, Spin will set up a dedicated "MariaDB" service for you with persistent volumes so you do not lose data when updating your container.
Default Configuration
The database uses the official MariaDB image. The default configuration allows us to:
- ✅ Quickly set up a database service with the exact version of our choice
- ✅ Automatically create databases, users, and passwords (defined by the
environment:
variables in thedocker-compose.*.yml
files)
⚠️ Special Connection Notes
Since the database is running in a container, you will need to connect to the database using the container name. For example, if you have a Laravel application, you would use the following in your .env
file:
Example .env File
DB_CONNECTION=mysql
DB_HOST=mariadb
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laraveluser
DB_PASSWORD=laravelpassword
From your development workstation, we expose the database service on port 3306
. This is the default port for MySQL and MariaDB. This means you can use localhost
and 3306
to connect to the database.
Usage
When you run spin up
, the MariaDB container will create our database and start the MariaDB service.