In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail the example analysis of the custom configuration of the official docker mysql image. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Previously, in order to save installation time, I started mysql with the official mysql docker image.
Pass through
$docker run-- name some-mysql-e MYSQL_ROOT_PASSWORD=my-secret-pw-d daocloud.io/mysql:tag
Some-mysql specifies the name of the container, my-secret-pw specifies the password of the root user, and the tag parameter specifies the MySQL version you want.
In this way, the data is not persistent, so you need to mount the local directory in the startup parameters.
So the database kept running, but recently the program needed to support emoji emoticons, so we had to change the character set of mysql.
$docker run-- name some-mysql-v / my/own/datadir:/var/lib/mysql-e MYSQL_ROOT_PASSWORD=my-secret-pw-d daocloud.io/mysql:tag
At this point, you can mount the custom configuration file, which is stated in the official document
When the MySQL service starts with / etc/mysql/my.cnf as the configuration file, this file imports all files in the / etc/mysql/conf.d directory with the suffix .cnf. These files extend or overwrite the configuration in the / etc/mysql/my.cnf file. So you can create your own configuration files and mount them to the / etc/mysql/conf.d directory in the MySQL container.
So the easiest way to change the database configuration is to create a new configuration file on the host and change it to utf8mb4
[client] default-character-set=utf8mb4 [mysqld] character-set-client-handshake = FALSEcharacter-set-server = utf8mb4collation-server = utf8mb4_unicode_ ci [MySQL] default-character-set=utf8mb4
Then copy the file to the appropriate docker container folder
Docker cp / home/my.cnf (host file path) [Container id]: / etc/mysql/mysql.conf.d
Finally, loading the custom configuration is achieved by restarting the container using the docker stop and start commands.
The container configured by the MySQL official image of Docker cannot be started.
I am using the Docker image of MySQL. First create and start the image:
# docker run-- name mysql-b\ >-p 33002 zc/mysql/datadir-b:/var/lib/mysql 3306-v / zc/mysql/datadir-b:/var/lib/mysql\ >-e MYSQL_ROOT_PASSWORD='123456'-d mysql:latest
Start normally, no problem. Usually when we use MySQL, we need to set parameters. To set the parameters, we need to enter the bash of the container and do the following:
Docker exec-it mysql-b bash
The default configuration file for MySQL is the / etc/mysql/my.cnf file. If you want to customize the configuration, it is recommended that you create a .cnf file in the / etc/mysql/conf.d directory. The newly created file can be named anything, as long as the suffix is cnf. Configuration items in the newly created file can overwrite configuration items in / etc/mysql/my.cnf. Because the official Docker image of MySQL does not provide a vim editor, I use the cat command to generate the file and add the content:
# cat > test.cnf
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.