当前位置:网站首页>docker安装mysql与宿主机相差8小时的问题。
docker安装mysql与宿主机相差8小时的问题。
2022-08-04 04:08:00 【抹香鲸之海】
最近用docker做了一个mysql的容器,启动发现里面的日期跟宿主机差了八个小时,起初以为是mysql的时区问题,后来发现是docker容器里面的时间问题。
进入宿主机和docker 内部 使用 date命令查询一下:
这是由于:
宿主机采用了CST时区,CST应该是指(China Shanghai Time,东八区时间)
容器采用了UTC时区,UTC应该是指(Coordinated Universal Time,标准时间)
解决:
因为我已经把容器起起来了,所以采用从宿主机拷贝到容器内部的方式,如果你还没有run起来容器,最好制作容器的时候就把时间文件挂载上。
docker cp /usr/share/zoneinfo/Asia/Shanghai mysql:/etc/localtime
重启一下:
docker restart mysql
验证一下:

已经同步了。
边栏推荐
- 2022支付宝C2C现金红包PHP源码DEMO/兼容苹果/安卓浏览器和扫码形式
- 深度学习——以CNN服装图像分类为例,探讨怎样评价神经网络模型
- Innovation and Integration | Huaqiu Empowerment Helps OpenHarmony Ecological Hardware Development and Landing
- 自定义通用分页标签02
- The video of machine learning to learn [update]
- 4-way two-way HDMI integrated business high-definition video optical transceiver 8-way HDMI high-definition video optical transceiver
- 2.15 keil使用电脑端时间日期
- 八年软件测试工程师带你了解-测试岗进阶之路
- MySQL查询优化与调优
- base address: environment variable
猜你喜欢

new Date converts strings into date formats Compatible with IE, how ie8 converts strings into date formats through new Date, how to replace strings in js, and explain the replace() method in detail

Based on the statistical QDirStat Qt directory

Explain详解与实践

高效IO模型

2022杭电多校联赛第五场 题解

2003. 每棵子树内缺失的最小基因值 DFS

打造一份优雅的简历

Reproduce 20-character short domain name bypass

Polygon zkEVM网络节点

如何简化现代电子采购的自动化?
随机推荐
FFmpeg —— 通过修改yuv,将视频转为黑白并输出(附源码)
文件系统的简单操作
十一种概率分布
typescript type 和 interface 的区别
The video of machine learning to learn [update]
SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropri
[Medical Insurance Science] To maintain the safety of medical insurance funds, we can do this
深度学习之 10 卷积神经网络3
Hey, I had another fight with HR in the small group!
解决问题遇到的问题
千兆2光8电管理型工业以太网交换机WEB管理X-Ring一键环网交换机
Enterprise live broadcast is on the rise: Witnessing focused products, micro-like embracing ecology
if,case,for,while
The general SQL injection flow (sample attached)
学会iframe并用其解决跨域问题
new Date converts strings into date formats Compatible with IE, how ie8 converts strings into date formats through new Date, how to replace strings in js, and explain the replace() method in detail
仿牛客论坛项目梳理
Polygon zkEVM network node
if,case,for,while
数据治理平台项目总结和分析