Skip to content

# MySQL Database Containerization Containerize your MySQL database with Docker. This repository provides a simple and efficient way to deploy a MySQL database using Docker.

Notifications You must be signed in to change notification settings

sidharth-chauhan/MySQL-Database-Containerization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MySQL Database Containerization

A MySQL database containerization with initialization scripts and data persistence.

Prerequisites

  • Docker installed on your system
  • Docker Compose installed on your system

#. Start the container

  • docker-compose up -d
  1. Verify container is running
  • docker ps
  1. Connect to MySQL mysql -h localhost -P 3306 -u user -p

Enter password: password

Configuration

Database Credentials

  • Database: mydb
  • Username: user
  • Password: password
  • Root Password: rootpassword

Port

  • MySQL Port: 3306

File Descriptions

Dockerfile

docker-compose.yml

  • Defines MySQL service
  • Sets up port mapping
  • Configures data persistence
  • Manages container restart policy

init.sql

  • Creates users table
  • Inserts sample data
  • Runs automatically on container creation

Common Commands

Start containers:

  • docker-compose up -d

Stop containers:

  • docker-compose down

View logs:

  • docker-compose logs

Access MySQL shell:

  • docker exec -it mysql-docker-db-1 mysql -u user -p

Remove everything including volumes:

  • docker-compose down -v

Data Persistence

Database data is persisted using Docker volumes. The data remains intact even if the container is removed.

Development

  1. Modify init.sql to change initial database structure
  2. Update docker-compose.yml for configuration changes
  3. Rebuild container after changes:
  • docker-compose down
  • docker-compose up -d --build

About

# MySQL Database Containerization Containerize your MySQL database with Docker. This repository provides a simple and efficient way to deploy a MySQL database using Docker.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published