当前位置:网站首页>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
验证一下:

已经同步了。
边栏推荐
- 缓存穿透、缓存击穿、缓存雪崩以及解决方案
- Senior PHP development case (1) : use MYSQL statement across the table query cannot export all records of the solution
- Eight guiding principles to help businesses achieve digital transformation success
- Use serve to build a local server
- 基地址:环境变量
- 马尔可夫链
- new Date将字符串转化成日期格式 兼容IE,ie8如何通过new Date将字符串转化成日期格式,js中如何进行字符串替换, replace() 方法详解
- mq应用场景介绍
- 文件内容的操作
- Basic characteristics of TL431 and oscillator circuit
猜你喜欢

自定义通用分页标签02

RSS订阅微信公众号初探-feed43

Reproduce 20-character short domain name bypass

Hey, I had another fight with HR in the small group!

MySQL query optimization and tuning

学会iframe并用其解决跨域问题

This Thursday evening at 19:00, the fourth live broadcast of knowledge empowerment丨The realization of equipment control of OpenHarmony smart home project

Deep learning -- CNN clothing image classification, for example, discussed how to evaluate neural network model
2022年软件测试——精选金融银行面试真题

将xml标签转换为txt(voc格式转换为yolo方便进行训练)
随机推荐
mysql index notes
技术解析|如何将 Pulsar 数据快速且无缝接入 Apache Doris
MySQL查询优化与调优
drools从下载到postman请求成功
张量篇-应用案例
[Medical Insurance Science] To maintain the safety of medical insurance funds, we can do this
How to automatically export or capture abnormal login ip and logs in elastic to the database?
7-3 LVS+Keepalived集群叙述与部署
怎么把elastic中的异常登录ip和日志自动导出或抓取到数据库中?
移动支付线上线下支付场景
帮助企业实现数字化转型成功的八项指导原则
Tensors - Application Cases
文件系统的简单操作
Stop behind.
创新互融|华秋赋能助力OpenHarmony生态硬件开发落地
FFmpeg —— 录制麦克风声音(附源码)
Embedded database development programming MySQL (full)
Explain detailed explanation and practice
SQL injection in #, - +, - % 20, % 23 is what mean?
杭电多校-Slipper-(树图转化+虚点建图)