Docker Compose MySQL & MariaDB Generator
Generate a docker-compose.yml for MySQL 8.0/8.4/9.x or MariaDB 10.6–11.8 in seconds. The tool sets the right MYSQL_* or MARIADB_* environment variables for the engine you pick, adds a named volume, a healthcheck that waits for InnoDB to initialise, optional init scripts, a custom my.cnf, phpMyAdmin or Adminer, and the correct legacy-authentication flag for each MySQL version. Everything runs in your browser — no data is uploaded.
- Files in ./initdb (.sql, .sql.gz, .sh) run only on first start, when the data volume is empty. Run `docker compose down -v` to re-trigger them.
- Config files in ./conf.d must be readable by the container's mysql user and not world-writable, otherwise the server logs 'World-writable config file is ignored'.
- MySQL 8 clients that fail with 'Authentication plugin caching_sha2_password cannot be loaded' need a newer connector — or the legacy-auth option above as a stopgap.
Do more than docker compose mysql & mariadb generator — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Choose MySQL or MariaDB and the version tag you want to run.
- Set the database name, user, passwords and the host port to publish.
- Toggle healthcheck, init script, config file and an admin UI, then copy the docker-compose.yml, .env and helper files.
Frequently asked questions
What is the difference between the MySQL and MariaDB compose files?
The images use different environment variable prefixes (MYSQL_ROOT_PASSWORD versus MARIADB_ROOT_PASSWORD, although the MariaDB image still accepts the MYSQL_ names), different healthchecks (mysqladmin ping versus the bundled healthcheck.sh --connect --innodb_initialized), different default collations (utf8mb4_0900_ai_ci exists only in MySQL 8+), and different client binaries (mysql/mysqldump versus mariadb/mariadb-dump). MariaDB also supports MARIADB_AUTO_UPGRADE to run mariadb-upgrade automatically after a major version bump.
Why can my application not authenticate against MySQL 8 in Docker?
MySQL 8.0 made caching_sha2_password the default authentication plugin, 8.4 disabled mysql_native_password entirely, and 9.0 removed it. Old connectors (PHP 7.0, older JDBC or Node mysql drivers) only speak mysql_native_password. The fix is to upgrade the driver; as a stopgap the generator can add --default-authentication-plugin=mysql_native_password (8.0) or --mysql-native-password=ON (8.4) to the command line.
How do I connect to the container from a GUI client?
Inside the compose network, containers reach the server at the service name on port 3306. From your host, connect to 127.0.0.1 on the published port with the MYSQL_USER or MARIADB_USER credentials. Chat2DB, a free AI SQL client for Windows, macOS and Linux, connects to both MySQL and MariaDB, shows the schema created by your init script, and lets you write queries in plain language.
