Set up the Employees Sample Mysql Database in Docker

S

Introduction

In this tutorial we will set up the employees sample Mysql database in a docker container and seed it with the Employees database from https://dev.mysql.com/doc/employee/en/employees-installation.html. To follow along you will need to have Docker installed

BUild the docker Image

The first step will be to build the docker image we will be using to stand up Postgres. To begin clone the repo https://github.com/monstarillo/monstarillo-templates. Open a command prompt and cd to the employees-db folder in the reop you just cloned. Create the docker image for our database with the command:

docker build -t monstarillo-mysql.
docker build command running in command prompt

This image includes the mysql database and scripts to seed it with the Employees database schema and data.

Create the container

Create the container by running the following command replacing <Your Password> with the password of your choice:

docker run --name monstarillo-mysql -e MYSQL_USER=admin -e MYSQL_PASSWORD=<Your Password> -e MYSQL_ROOT_PASSWORD=<Your Password> -p 3306:3306 -d monstarillo-mysql

This command creates a user named admin with the password you provide in addition to the root user. The JDBC URL for your database will be

jdbc:mysql://localhost:3306/employees

The username is admin and the default schema is employees. The admin user’s password will be the password you used in the docker run command above.

You have set up the employees sample Mysql database in docker.

Next you can Generate a REST API Using Java for a MYSQL database or Generate a Rest API Using Go for a MySql Database.

About the author

Patrick Wright

2 Comments

Patrick Wright

Get in touch