MySQL Docker environment variables¶
When deploying a MySQL database within a Docker container, environment variables are used to configure the root password, create specific users, and initialize databases upon the first startup.^[600-developer-docker-docker-compose-docker-compouse-02.md]
Configuration¶
In a docker-compose.yml file, these variables are typically defined under the environment section of the service definition.^[600-developer-docker-docker-compose-docker-compouse-02.md]
Key Variables¶
Common variables used to configure the MySQL container include:
MYSQL_ROOT_PASSWORD: This mandatory variable sets the password for the MySQLrootsuperuser.^[600-developer-docker-docker-compose-docker-compouse-02.md]MYSQL_DATABASE: This variable specifies the name of the database to be created when the image is first started.^[600-developer-docker-docker-compose-docker-compouse-02.md]MYSQL_USER: Used in conjunction withMYSQL_PASSWORD, this variable creates a new user with superuser privileges specifically for the database defined byMYSQL_DATABASE.^[600-developer-docker-docker-compose-docker-compouse-02.md]MYSQL_PASSWORD: Sets the password for the user created by theMYSQL_USERvariable.^[600-developer-docker-docker-compose-docker-compouse-02.md]
Sources¶
600-developer-docker-docker-compose-docker-compouse-02.md