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

Building .NET Core 2.0 + Nginx + Supervisor environment under Centos7 system

1. Introduction to Linux .NET Core Microsoft has ...

Will mysql's in invalidate the index?

Will mysql's IN invalidate the index? Won'...

Introduction and use of js observer mode

Table of contents I. Definition 2. Usage scenario...

Common styles of CSS animation effects animation

animation Define an animation: /*Set a keyframe t...

Detailed example of IOS database upgrade data migration

Detailed example of IOS database upgrade data mig...

Implementing timed page refresh or redirect based on meta

Use meta to implement timed refresh or jump of th...

Detailed explanation of the execution process of mysql update statement

There was an article about the execution process ...

JavaScript message box example

Three types of message boxes can be created in Ja...

Graphical steps of zabbix monitoring vmware exsi host

1. Enter the virtualization vcenter, log in with ...

Better looking CSS custom styles (title h1 h2 h3)

Rendering Commonly used styles in Blog Garden /*T...

How to install Postgres 12 + pgadmin in local Docker (support Apple M1)

Table of contents introduce Support Intel CPU Sup...

How to handle MySQL numeric type overflow

Now, let me ask you a question. What happens when...

Analyze the method of prometheus+grafana monitoring nginx

Table of contents 1. Download 2. Install nginx an...

jQuery implements the function of adding and deleting employee information

This article shares the specific code of jQuery t...