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

MySQL sorting feature details

Table of contents 1. Problem scenario 2. Cause An...

In-depth understanding of MySQL self-connection and join association

1. MySQL self-connection MySQL sometimes needs to...

Using Docker+jenkins+python3 environment to build a super detailed tutorial

Preface: After the automation is written, it need...

Detailed analysis of when tomcat writes back the response datagram

The question arises This question arose when I wa...

Detailed explanation of setting up DNS server in Linux

1. DNS server concept Communication on the Intern...

Win10 configuration tomcat environment variables tutorial diagram

Before configuration, we need to do the following...

Usage of Node.js http module

Table of contents Preface HTTP HTTP Server File S...

How to install and configure WSL on Windows

What is WSL Quoting a passage from Baidu Encyclop...

Implementing a simple calculator with javascript

This article example shares the specific code of ...

Implementing Markdown rendering in Vue single-page application

When rendering Markdown before, I used the previe...

Mysql database recovery actual record by time point

Introduction: MySQL database recovery by time poi...

Architecture and component description of docker private library Harbor

This article will explain the composition of the ...

idea uses docker plug-in to achieve one-click automated deployment

Table of contents environment: 1. Docker enables ...

Do you know why vue data is a function?

Official website explanation: When a component is...