Skip to content

Deniel11/mysql-docker-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐬 MySQL Docker Container Management Scripts

This project provides simple Bash scripts for managing a MySQL container using Docker.
The scripts allow you to easily create, start, stop, or delete a MySQL container using your own configuration.


📦 Included Scripts

  • create.sh – Creates and starts a new MySQL Docker container
  • delete.sh – Stops and deletes the container (if exists)
  • start.sh – Starts the container (or asks to stop if already running)
  • stop.sh – Stops the container (or asks to start if not running)
  • config.env – Configuration file containing all required environment variables

⚙️ Configuration

Edit the config.env file before using the scripts. Example content:

CONTAINER_NAME=mysql-container
MYSQL_ROOT_PASSWORD=secret
MYSQL_DATABASE=schedule
MYSQL_USER=user
MYSQL_PASSWORD=password
MYSQL_PORT=3307
MYSQL_VERSION=latest

🖥️ Script Options

Each script accepts an optional --no-wait flag:

  • --no-wait: Skips the "Press any key to exit..." prompt at the end
    (useful when calling one script from another)

Example:

./create.sh --no-wait

🚦 Script Behaviors

  • If the container already exists:
    • You'll be prompted whether to delete or start/stop it depending on the script
  • If the container does not exist:
    • The scripts offer to create it (in case of delete.sh or stop.sh)
  • Colorful icons and messages indicate status and next steps

📝 License

Feel free to reuse and modify.


👶 Very Simple Guide (for Non-Technical Users)

1. 🐳 Install Docker


2. 📁 Prepare the Scripts

  • Download or copy all files into one folder:
    • create.sh
    • delete.sh
    • start.sh
    • stop.sh
    • config.env

3. 🛠️ Make Scripts Executable

On Windows:

  • These scripts are written in Bash, not Windows .bat files
  • You need a Linux-style environment, such as:
    • Git Bash (recommended): https://git-scm.com
    • WSL (Windows Subsystem for Linux): install via Microsoft Store

On macOS:

  • You can use the built-in Terminal to run .sh scripts
  • If needed, give the scripts permission to run:
chmod +x *.sh

✅ After setup, the scripts are also runnable by double-clicking in file managers (on macOS or Linux, depending on system settings), but it's more reliable to run them from a terminal.


4. ⚙️ Edit the Configuration

Open config.env with any text editor and change values if needed:

CONTAINER_NAME=mysql-container
MYSQL_ROOT_PASSWORD=my-secret-pw
MYSQL_DATABASE=my_database
MYSQL_USER=user
MYSQL_PASSWORD=password
MYSQL_PORT=3307
MYSQL_VERSION=latest

5. 🚀 Run the Scripts

Open a terminal and go to the folder:

cd path/to/the/folder

Then use these commands:

  • Create MySQL container:
./create.sh
  • Start container if stopped:
./start.sh
  • Stop the container:
./stop.sh
  • Delete the container:
./delete.sh

You’ll be asked simple yes/no questions during execution. Just type y or n and press Enter.


6. 🧩 Connect to the Database

Use tools like DBeaver or HeidiSQL, and connect with:

  • Host: localhost
  • Port: the one in config.env (default: 3307)
  • User: root
  • Password: from config.env

✅ You do not need to understand Docker. These scripts take care of everything.

About

Interactive MySQL Docker container management scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages