Docker installs mysql and solves the Chinese garbled problem

Docker installs mysql and solves the Chinese garbled problem

1. Pull the mysql image

Website: https://hub.docker.com/

insert image description here

insert image description here

Copy the command to download: docker pull mysql[:版本號]
Without version number, the latest version is used by default

insert image description here

2. Check whether the download is complete

docker images 

insert image description here

3. MySQL mounts local directory & solves Chinese garbled characters

Because there is no vi command in the container, we can mount數據and配置on the host machine to facilitate our operation.

Create folders separately

/tmp/mysql/data
/tmp/mysql/conf
Create the hmy.cnf file in the conf folder and copy the following content into it
Solve the problem of Chinese garbled characters, so that Chinese characters will not be garbled when you search

[mysqld] 
skip-name-resolve
character_set_server=utf8
datadir=/var/lib/mysql
server-id=1000
[mysql] 
default-character-set = utf8
[mysql.server]
default-character-set = utf8
[mysqld_safe]
default-character-set = utf8
[client]
default-character-set = utf8

insert image description here

4. Create a container and view it

Create command:

docker run \
 --name mysql \
 -p 3306:3306 \
 --privileged=true -v /tmp/mysql/data:/var/lib/mysql \
 -v /tmp/mysql/conf/hmy.cnf:/etc/mysql/conf.d/hmy.cnf \
 -e MYSQL_ROOT_PASSWORD=123456 \
 -d \
 mysql:latest

insert image description here

Check whether the creation is successful:

docker ps -a 

insert image description here

If you accidentally create an error, you can delete docker rm -f 創建的名字

insert image description here

Enter the mysql container: docker exec -it mysql bash

Use Navicat to test whether it is started

insert image description here

Test whether Chinese characters are garbled

insert image description here

This is the end of this article about the detailed tutorial on how to install MySQL on Docker and solve the problem of Chinese garbled characters that I have tested myself. For more related content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Docker installation and configuration steps for MySQL
  • How to install MySQL and Redis in Docker
  • Detailed steps for installing Tomcat, MySQL and Redis with Docker
  • How to install mysql in docker
  • Tutorial on installing MySQL with Docker and implementing remote connection
  • MySQL 8.0.20 installation and configuration tutorial under Docker
  • How to install MySQL 8.0 in Docker

<<:  How to center the entire page content so that the height can adapt to the content and automatically expand

>>:  MySQL series multi-table join query 92 and 99 syntax examples detailed tutorial

Recommend

What is MIME TYPE? MIME-Types type collection

What is MIME TYPE? 1. First, we need to understand...

Vue+Echart bar chart realizes epidemic data statistics

Table of contents 1. First install echarts in the...

Docker solution for logging in without root privileges

When you use the docker command for the first tim...

JavaScript anti-shake and throttling explained

Table of contents Stabilization Throttling Summar...

Solution to the problem of MySQL data delay jump

Today we analyzed another typical problem about d...

mysql method to recursively search for all child nodes of a menu node

background There is a requirement in the project ...

JavaScript imitates Taobao magnifying glass effect

This article shares the specific code for JavaScr...

Complete steps for using Echarts and sub-packaging in WeChat Mini Program

Preface Although the holiday is over, it shows up...

Detailed explanation of Nginx process scheduling problem

Nginx uses a fixed number of multi-process models...

Summary of the understanding of virtual DOM in Vue

It is essentially a common js object used to desc...

Example operation MySQL short link

How to set up a MySQL short link 1. Check the mys...

The whole process of IDEA integrating docker to deploy springboot project

Table of contents 1. IDEA downloads the docker pl...