当前位置:网站首页>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
边栏推荐
- [flask] crud addition and query operation of data
- Several ways of MySQL database optimization (pen interview must ask)
- Redis distributed lock implementation redison 15 questions
- 硬件工程师的真实前途我说出来可能你们不信
- 四川云教和双师模式
- Contest3145 - the 37th game of 2021 freshman individual training match_ B: Password
- May brush question 27 - figure
- Why can't TN-C use 2p circuit breaker?
- tn-c为何不可用2p断路器?
- 33岁可以学PLC吗
猜你喜欢

C杂讲 文件 初讲

PR 2021 quick start tutorial, first understanding the Premiere Pro working interface

Cap theory

MapReduce instance (V): secondary sorting

Embedded development is much more difficult than MCU? Talk about SCM and embedded development and design experience

Nc17 longest palindrome substring

Which is the better prospect for mechanical engineer or Electrical Engineer?

I2C summary (single host and multi host)

C#/. Net phase VI 01C Foundation_ 01: running environment, process of creating new C program, strict case sensitivity, meaning of class library

CANoe的数据回放(Replay Block),还是要结合CAPL脚本才能说的明白
随机推荐
【深度学习】语义分割:论文阅读:(2021-12)Mask2Former
There are software load balancing and hardware load balancing. Which one to choose?
MapReduce instance (x): chainmapreduce
通过bat脚本配置系统环境变量
Automation sequences of canoe simulation functions
CANoe CAPL文件操作目录合集
Release of the sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
How can I take a shortcut to learn C language in college
C杂讲 文件 初讲
Nc17 longest palindrome substring
Defensive C language programming in embedded development
发生OOM了,你知道是什么原因吗,又该怎么解决呢?
C杂讲 浅拷贝 与 深拷贝
Why data Tiering
手把手教您怎么编写第一个单片机程序
A wave of open source notebooks is coming
Summary of May training - from a Guang
Regular expressions are actually very simple
五月刷题27——图
112 pages of mathematical knowledge sorting! Machine learning - a review of fundamentals of mathematics pptx