mysql-docker-environment-configuration¶
mysql-docker-environment-configuration refers to the setup and definition of runtime variables when deploying a MySQL database container using Docker Compose.
Configuration Parameters¶
When deploying MySQL with Docker Compose, environment variables are passed within the service definition to control the behavior and access of the database instance^[600-developer__docker__docker-compose__docker-compouse-02.md].
Credentials and Database Creation¶
The configuration typically involves setting environment variables to establish the database schema and user permissions^[600-developer__docker__docker-compose__docker-compouse-02.md]. Common variables include:
MYSQL_ROOT_PASSWORD: Sets the password for the MySQLrootsuperuser account^[600-developer__docker__docker-compose__docker-compouse-02.md].MYSQL_DATABASE: Specifies the name of the database to be created upon initialization^[600-developer__docker__docker-compose__docker-compouse-02.md].MYSQL_USER: Creates a new user with the specified name^[600-developer__docker__docker-compose__docker-compouse-02.md].MYSQL_PASSWORD: Sets the password for the user created byMYSQL_USER^[600-developer__docker__docker-compose__docker-compouse-02.md].
Example Configuration¶
The following docker-compose.yml snippet demonstrates a typical configuration for a MySQL 5.7 service named db^[600-developer__docker__docker-compose__docker-compouse-02.md]:
version: "3"
services:
db:
image: mysql:5.7
environment:
- MYSQL_USER=tommy
- MYSQL_PASSWORD=tommy
- MYSQL_DATABASE=dockerDb
- MYSQL_ROOT_PASSWORD=root
Related Concepts¶
- Docker Compose
- [[MySQL]]
- [[Environment Variables]]
Sources¶
^[600-developer__docker__docker-compose__docker-compouse-02.md]