In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
directory structure
.│ .env│ docker-compose.yml│└─mysql ├─config │ my.cnf │ └─data
mysql directory data for the data directory, mysql data table, binary log files here. The env file contains variables that can be referenced in the docker-compose.yml file as ${variable_name}.
Of course, you can also put mysql directory to other places, here figure a convenient, directly placed in the yml file peer directory.
.env file
MYSQL_ROOT_PASSWORD=rootMYSQL_ROOT_HOST=%MYSQL_DIR=./ mysql
MySQL configuration file my.cnf
[mysqld]character-set-server=utf8mb4default-time-zone='+8:00'innodb_rollback_on_timeout='ON'max_connections=500innodb_lock_wait_timeout=500
This file can be omitted if the default configuration is used.
docker-compose.yml
version: '3'services: mysql-db: container_name: mysql-docker #Specify the name of the container image: mysql:8.0 #Specify mirror and version ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_ROOT_HOST: ${MYSQL_ROOT_HOST} volumes: - "${MYSQL_DIR}/data:/var/lib/mysql" #Mount data directory- "${MYSQL_DIR}/config:/etc/mysql/conf.d" #Mount configuration file directory
Environment variable
MYSQL_ROOT_PASSWORD: This unexplained, root password. MYSQL_USER, MYSQL_PASSWORD: These two variables are optional and create a new user with superuser privileges on the database specified by the MYSQL_DATABASE variable. MYSQL_DATABASE: Specifies a database to be created at container startup. MYSQL_ALLOW_EMPTY_PASSWORD: Set to yes to allow root user passwords to be blank. MYSQL_RANDOM_ROOT_PASSWORD: Set to yes to generate a random password for root at container startup, and the password appears in the standard output stream (GENERATED ROOT PASSWORD: ...). MYSQL_ONETIME_PASSWORD: Literally means one-time password, set for root user, password must be changed after first login (only supports version 5.6 and above).
run containers
Execute in docker-compose.yml directory:
> docker-compose up
If you want to run in the background, use docker-compose up -d.
Stop container:
> docker-compose down
If running foreground, use Ctrl + C to stop. Both methods delete containers after stopping, and the next time you start, you must use the up command.
Stop without deleting containers:
> docker-compose stop
After stopping with stop, start again with start command.
summary
The above is a small series to introduce you to the use of docker-compose MySQL method, I hope to help you, if you have any questions please give me a message, small series will reply to you in time. Thank you very much for your support! If you think this article is helpful to you, welcome to reprint, please indicate the source, thank you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.