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.
create.sh– Creates and starts a new MySQL Docker containerdelete.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
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=latestEach 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- 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.shorstop.sh)
- The scripts offer to create it (in case of
- Colorful icons and messages indicate status and next steps
Feel free to reuse and modify.
- Visit: https://www.docker.com/products/docker-desktop
- Download and install Docker Desktop for Windows or macOS
- After installation, start Docker Desktop and make sure it's running in the background
- Download or copy all files into one folder:
create.shdelete.shstart.shstop.shconfig.env
- These scripts are written in Bash, not Windows
.batfiles - You need a Linux-style environment, such as:
- Git Bash (recommended): https://git-scm.com
- WSL (Windows Subsystem for Linux): install via Microsoft Store
- You can use the built-in Terminal to run
.shscripts - 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.
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=latestcd 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.shYou’ll be asked simple yes/no questions during execution. Just type y or n and press Enter.
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.