当前位置:网站首页>Execute the mysql script file in the docker mysql container and solve the garbled characters
Execute the mysql script file in the docker mysql container and solve the garbled characters
2022-08-03 19:02:00 【Lanzhou Qianfan】
docker 容器中执行mysqlscript files and resolve garbled characters
Searched a lot online,在容器mysqlIs it so hard to execute a piece of code in ?Make it very complicated. So record it yourself,虽然简单,But still afraid of forgetting it later,Search for a long time.
The need now is to be minesql文件导入进来,然后让docker中的mysql 来执行它.
注意mysql在docker容器中,If you only import to the host machine,Then enter the container to executesql文件的话,It will tell you that it cannot be opened,Because the outside of the host and the inside of the container are relatively isolated,It is impossible to find the path of the host inside the container.
因此,All we have to do is put the host machinesqlThe file is copied inside the container,Then let it execute,这样就好了. 我把sqlfiles are placed here,Here is what I used to do anddocker sqlOrdinary directory for file mounts,当然,You can put it anywhere now.
To copy to the inside of the container,You need to find the container first. 首先列举出来,Take a look at running containers,对应mysql的id就知道了.
docker ps然后我们通过id to specify the container,这个也就是mysql容器的id We can enter the container with this command,We go in here,You can log in heremysql,然后执行脚本.
docker exec -it 4f50fbeb15ee /bin/bashctrl+d,退出容器 但是在这之前,我们要将sql文件拷贝进来.
docker cp /mysql/mysql/1.sql 4f50fbeb15ee:/home/1.sqlcpThe back is your host computersql文件所在的路径,容器idThe latter one is the containerhome文件夹,One is named after I copied itsql文件.Copy here.
after copying,We go into the container again.
docker exec -it 4f50fbeb15ee /bin/bashThen we go into the containerhome
cd homeCheck to see if there is one in the directory1.sql,View inside the container is not availablell,所以用ls
ls有的 在容器中执行,Just use the path in the container,It has nothing to do with the host path. 然后我们就执行
source /home/1.sql但是有的时候啊,执行完毕后,He will have some gibberish.
So we can try to look at some encodings
show variables like '%char%';I changed all these encodings to utf-8
set character_set_client=utf8;
set character_set_connection=utf8;
set character_set_database=utf8;
set character_set_results=utf8;
set character_set_server=utf8;这样做是有效的,Later, the fields with garbled characters in my database were all normal.
边栏推荐
- MPLS的简单应用于实验
- 阿里巴巴政委体系-第七章、阿里政委培育
- Selenium of reptiles
- 【ORACLE】什么时候ROWNUM等于0和ROWNUM小于0,两个条件不等价?
- fatal error: jni.h: No such file or directory
- Online monitoring of UPS power supply and operating environment in the computer room, the solution is here
- 分享即时通讯开发之WebSocket:概念、原理、易错常识、动手实践
- 技术开发人员常用的安全浏览器
- 【C语言学习笔记(七)】C语言重定向输入与输出
- ImportError: /lib/libgdal.so.26: undefined symbol: sqlite3_column_table_name
猜你喜欢

Alibaba senior experts create a learning architecture from scratch, including Alibaba's internal technology stack PPT, PFD actual combat

WEB 渗透之RCE

Mkke:为什么无法从Oracle 11g或12c升级到Oracle 23c?

微信小程序分享功能

Confused!Ali was abused on the one hand, but was fortunate to be promoted to Huawei's technology, and successfully got the offer, with an annual salary of 40w

图像超分——Real-ESRGAN快速上手

Arduino实验三:继电器实验

MPLS的简单应用于实验

阿里资深架构师钟华曰:中台战略思想与架构实战;含内部实施手册

基于DMS的数仓智能运维服务,知多少?
随机推荐
要想成为黑客,离不开这十大基础知识
U-Net生物医学图像分割讲解(Convolutional Networks for BiomedicalImage Segmentation)
图像超分——Real-ESRGAN快速上手
【QT】入门心法
87. (Home of cesium) cesium heat map (topography)
七夕之前,终于整出了带AI的美丽秘笈
pytest接口自动化测试框架 | Jenkins集成初探
使用安全浏览器将网页保存为pdf的方法步骤
【夜莺监控方案】08-监控msyql集群(prometheuse+n9e+mysqld_exporter)
POJ 3041 Asteroids(最大匹配数=最小点覆盖)
基于ck+redash构建MySQL慢日志+审计日志展示平台
阿里巴巴政委体系-第九章、阿里政委启示录
MySQL详细学习教程(建议收藏)
ScrollView嵌套RV,滑动有阻力不顺滑怎么办?
首届MogDB征文活动开启啦!
阿里资深专家打造从零开始学架构,含阿里内部技术栈PPT、PFD实战
mysql跨库关联查询(dblink)
sys文件系统
讯方实训云平台——加速教育高质量发展的“数字底座”!
[数据集][VOC]老鼠数据集voc格式3001张