Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install mysql and solve the problem of Chinese garbled in Docker

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "Docker how to install mysql and solve the Chinese garbled problem", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "Docker how to install mysql and solve the Chinese garbled problem" this article.

1. Pull mysql image

Web site: https://hub.docker.com/

Copy command to download: docker pull mysql [: version number]

Do not add the version number. The default is the latest version.

two。 Check to see if the download of docker images is complete

3.MySQL mounts the local directory & solves Chinese garbled

Since there is no vi command in the container, we can mount the data and configuration on the host to facilitate our operation.

Create separate folders

/ tmp/mysql/data

/ tmp/mysql/conf

Create the hmy.cnf file under the file conf folder, and copy the following

Solve the problem of Chinese garbled, so that when you query, the Chinese will not garble.

[mysqld] skip-name-resolvecharacter_set_server=utf8datadir=/var/lib/mysqlserver-id=1000 [mysql] default-character-set = UTF8 [mysql.server] default-character-set = UTF8 [mysqld _ safe] default-character-set = UTF8 [client] default-character-set = utf8

4. Create a container and view

Create a command:

Docker run\-name mysql\-p 3306 tmp/mysql/data:/var/lib/mysql 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

Check to see if it was created successfully:

Docker ps-a

If you accidentally create an error, you can delete it through the name created by docker rm-f

Enter the mysql container: docker exec-it mysql bash

Test whether or not to start using Navicat

Test whether the Chinese code is garbled

The above is all the contents of the article "how to install mysql in Docker and solve the problem of garbled codes in Chinese". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report