当前位置:网站首页>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
边栏推荐
猜你喜欢
C#/. Net phase VI 01C Foundation_ 01: running environment, process of creating new C program, strict case sensitivity, meaning of class library
CANoe仿真功能之自动化序列(Automation Sequences )
CAPL script printing functions write, writeex, writelineex, writetolog, writetologex, writedbglevel do you really know which one to use under what circumstances?
MapReduce instance (IV): natural sorting
[CV] target detection: derivation of common terms and map evaluation indicators
Target detection -- yolov2 paper intensive reading
[one click] it only takes 30s to build a blog with one click - QT graphical tool
CAPL脚本中关于相对路径/绝对路径操作的几个傻傻分不清的内置函数
《ASP.NET Core 6框架揭秘》样章发布[200页/5章]
Programmation défensive en langage C dans le développement intégré
随机推荐
Leetcode:608 tree node
CANoe仿真功能之自动化序列(Automation Sequences )
Canoe CAPL file operation directory collection
Random notes
华南技术栈CNN+Bilstm+Attention
Inject common SQL statement collation
嵌入式開發中的防禦性C語言編程
51单片机进修的一些感悟
嵌入式开发中的防御性C语言编程
Cooperative development in embedded -- function pointer
Mapreduce实例(五):二次排序
May brush question 03 - sorting
Elk project monitoring platform deployment + deployment of detailed use (II)
Control the operation of the test module through the panel in canoe (primary)
Some thoughts on the study of 51 single chip microcomputer
Keep these four requirements in mind when learning single chip microcomputer with zero foundation and avoid detours
May brush question 27 - figure
Safety notes
【深度学习】语义分割:论文阅读(NeurIPS 2021)MaskFormer: per-pixel classification is not all you need
VH6501学习系列文章