In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to solve the problem of inconsistency between mysql time and system time in docker. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
When I installed mysql in Docker recently, I found that there was a difference of 8 hours between the database time and the system time.
Linux server time:
Enter mysql and enter date as follows
It is found that the two time zones are different. Because the mysql container is installed in docker, the mistiming of the mysql should be caused by the host docker.
According to the query data, the default time zone of docker is zone 0, which will cause a lot of trouble to the installed container, such as inaccurate recording of execution logs.
There are two ways to solve the problem:
Method 1: copy the localtime of the host
Docker cp / etc/localtime [Container ID or NAME]: / etc/localtime
Note: because of the time zone problem, the above command may report the following error
Error response from daemon: Error processing tar file (exit status 1):
Invalid symlink "/ usr/share/zoneinfo/UCT"-> ".. / usr/share/zoneinfo/Asia/Shanghai"
View this file
Found that this file refers to an address
Solution: toggle command
Docker cp / usr/share/zoneinfo/Asia/Shanghai [Container ID or NAME]: / etc/localtime
Then restart the container
Docker restart [Container ID or NAME]
Method 2: share the localtime of the host
Specify the startup parameters when creating the container, and mount the localtime file into the container
Docker run-- name-v / etc/localtime container id:/etc/localtime:ro.
The problem of inconsistency between the two time zones is solved.
This is the end of this article on "how to solve the problem of inconsistency between mysql time and system time in docker". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.