当前位置:网站首页>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
边栏推荐
- Contest3145 - the 37th game of 2021 freshman individual training match_ B: Password
- Several ways of MySQL database optimization (pen interview must ask)
- May brush question 01 - array
- Listen to my advice and learn according to this embedded curriculum content and curriculum system
- Mapreduce实例(五):二次排序
- Oom happened. Do you know the reason and how to solve it?
- Une grande vague d'attaques à la source ouverte
- CAPL 脚本对.ini 配置文件的高阶操作
- 嵌入式开发比单片机要难很多?谈谈单片机和嵌入式开发设计经历
- 一大波开源小抄来袭
猜你喜欢

Nc29 search in two-dimensional array

Target detection -- yolov2 paper intensive reading

CANoe的数据回放(Replay Block),还是要结合CAPL脚本才能说的明白

MapReduce instance (VI): inverted index

MapReduce instance (VIII): Map end join

Solve the problem of too many small files

The replay block of canoe still needs to be combined with CAPL script to make it clear

MapReduce instance (IV): natural sorting

MapReduce working mechanism

Interview shock 62: what are the precautions for group by?
随机推荐
tn-c为何不可用2p断路器?
学习单片机对社会的帮助是很大的
一大波開源小抄來襲
华南技术栈CNN+Bilstm+Attention
Regular expressions are actually very simple
CANoe仿真功能之自动化序列(Automation Sequences )
Single chip microcomputer realizes modular programming: Thinking + example + system tutorial (the degree of practicality is appalling)
零基础学习单片机切记这四点要求,少走弯路
Release of the sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
CAPL 脚本打印函数 write ,writeEx ,writeLineEx ,writeToLog ,writeToLogEx ,writeDbgLevel 你真的分的清楚什么情况下用哪个吗?
CAPL script printing functions write, writeex, writelineex, writetolog, writetologex, writedbglevel do you really know which one to use under what circumstances?
Target detection -- yolov2 paper intensive reading
Random notes
Hero League rotation map automatic rotation
112 pages of mathematical knowledge sorting! Machine learning - a review of fundamentals of mathematics pptx
嵌入式开发中的防御性C语言编程
June brush question 01 - array
Scoped in webrtc_ refptr
51单片机进修的一些感悟
Some thoughts on the study of 51 single chip microcomputer