当前位置:网站首页>docker MySQL解决时区问题
docker MySQL解决时区问题
2022-07-06 09:05:00 【向涛歌学习】
前言
MySQL中插入数据的当前时间少了8个小时,在网上查资料得知是没有设置时区,使用的系统时区。
通过命令
show variables like "%time_zone%"
可以查看时区:
更改配置文件my.cnf:
[mysqld]
default-time-zone='+08:00'
然后重启MySQL,再查看time_zone:
附docker-compose.yml:
my_mysql:
image: mysql:8.0
container_name: my_mysql
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --explicit_defaults_for_timestamp=true --lower_case_table_names=1
restart: always
volumes:
- /root/jzt/docker/mysql/data:/var/lib/mysql/ #映射mysql的数据目录到宿主机,保存数据
- /root/jzt/docker/mysql/conf/my.cnf:/etc/mysql/my.cnf #把mysql的配置文件映射到容器的相应目录
- /root/jzt/docker/mysql/logs:/logs
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: xxx
# 初始化用户(不能是root 会报错, 后续需要给新用户赋予权限)
MYSQL_USER: xxx
# 用户密码
MYSQL_PASSWORD: xxx
边栏推荐
- CANoe下载地址以及CAN Demo 16的下载与激活,并附录所有CANoe软件版本
- 单片机如何从上电复位执行到main函数?
- 33岁可以学PLC吗
- Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions
- Mapreduce实例(五):二次排序
- Contest3145 - the 37th game of 2021 freshman individual training match_ C: Tour guide
- [NLP] bert4vec: a sentence vector generation tool based on pre training
- Solve the problem of too many small files
- 机械工程师和电气工程师方向哪个前景比较好?
- MapReduce instance (V): secondary sorting
猜你喜欢
[deep learning] semantic segmentation: paper reading: (2021-12) mask2former
Interview shock 62: what are the precautions for group by?
C#/. Net phase VI 01C Foundation_ 01: running environment, process of creating new C program, strict case sensitivity, meaning of class library
Keep these four requirements in mind when learning single chip microcomputer with zero foundation and avoid detours
I2C summary (single host and multi host)
一大波开源小抄来袭
Learning SCM is of great help to society
33岁可以学PLC吗
If a university wants to choose to study automation, what books can it read in advance?
Several silly built-in functions about relative path / absolute path operation in CAPL script
随机推荐
CANoe的数据回放(Replay Block),还是要结合CAPL脚本才能说的明白
Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions
33岁可以学PLC吗
单片机实现模块化编程:思维+实例+系统教程(实用程度令人发指)
为什么大学单片机课上51+汇编,为什么不直接来STM32
《ASP.NET Core 6框架揭秘》样章发布[200页/5章]
[one click] it only takes 30s to build a blog with one click - QT graphical tool
嵌入式中的合作开发--函数指针
Basic concepts of libuv
Counter attack of noodles: redis asked 52 questions in a series, with detailed pictures and pictures. Now the interview is stable
History of object recognition
Mapreduce实例(七):单表join
Selection of software load balancing and hardware load balancing
[Yu Yue education] Wuhan University of science and technology securities investment reference
max-flow min-cut
Safety notes
华南技术栈CNN+Bilstm+Attention
Contrôle de l'exécution du module d'essai par panneau dans Canoe (primaire)
[deep learning] semantic segmentation: paper reading: (2021-12) mask2former
Segmentation sémantique de l'apprentissage profond - résumé du code source