In this article, We will explain to you how to set up MariaDB following multiple databases using Docker-Compose
- mydb (use can use it for local development)
- test (use can use it for testing)
The production database environment. You can use cloud databases such as AWS RDS, Heroku, etc.
A dedicated environment for database for local development.
A dedicated environment for database testing.
Why we need multiple databases?
If you have only a Production Database and you are developing a new feature if something breaks it will affect the whole Production Database.
For best practice, You must have a different Database Development Environment because if you are developing a new feature in a Development Environment if something breaks it will not impact on Production Database Environment.
Let’s Start Creating Multiple Environment Database
Hope you are familiar with “Docker-Compose”
├── docker-compose.yml (File)
├── init (Directory)
│ ├── 01.sql (File)
Create a new file docker-compose.yml
Above file, we have created a MariaDB Docker container with default Port No: 3306
As well as set environment variables such as default username, password of MariaDB container.
if you check the entire file we have also created volumes that point to the `./init:/docker-entrypoint-initdb.d` file.
The script inside “init/01.sql” will create multiple databases upon container startup. You can see the following file we have created 1 new…