码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • mysql 默认时间写入时差问题


    1)设置linux系统时间,这以centos为例

    1. // 查看时间
    2. [root@localhost ~]# date
    3. 2022年 08月 03日 星期三 19:34:21 CST
    4. // 同步网络时间
    5. [root@localhost ~]# yum -y install ntp ntpdate
    6. 已加载插件:fastestmirror
    7. Loading mirror speeds from cached hostfile
    8. epel/x86_64/metalink | 6.6 kB 00:00:00
    9. * base: mirrors.ustc.edu.cn
    10. * epel: mirrors.bfsu.edu.cn
    11. * extras: mirrors.njupt.edu.cn
    12. * updates: mirrors.njupt.edu.cn
    13. base | 3.6 kB 00:00:00
    14. docker-ce-stable | 3.5 kB 00:00:00
    15. epel | 4.7 kB 00:00:00
    16. extras | 2.9 kB 00:00:00
    17. updates | 2.9 kB 00:00:00
    18. (1/2): epel/x86_64/updateinfo | 1.1 MB 00:00:05
    19. (2/2): epel/x86_64/primary_db | 7.0 MB 00:00:17
    20. 软件包 ntp-4.2.6p5-29.el7.centos.2.x86_64 已安装并且是最新版本
    21. 软件包 ntpdate-4.2.6p5-29.el7.centos.2.x86_64 已安装并且是最新版本
    22. 无须任何处理
    23. [root@localhost ~]# ntpdate cn.pool.ntp.org
    24. 4 Aug 10:43:19 ntpdate[2007]: step time server 139.199.215.251 offset 54409.400114 sec
    25. [root@localhost ~]# hwclock --systohc
    26. // 查看时间
    27. [root@localhost ~]# date
    28. 2022年 08月 04日 星期四 10:43:42 CST
    29. // 查看时差
    30. [root@localhost ~]# timedatectl
    31. Local time: 四 2022-08-04 10:45:31 CST
    32. Universal time: 四 2022-08-04 02:45:31 UTC
    33. RTC time: 四 2022-08-04 02:45:25
    34. Time zone: Asia/Shanghai (CST, +0800)
    35. NTP enabled: yes
    36. NTP synchronized: no
    37. RTC in local TZ: no
    38. DST active: n/a
    39. // 如果时差有问题 设置时差
    40. [root@localhost ~]# timedatectl set-timezone Asia/Shanghai

    2)如果是容器部署mysql  设置容器时间

    1. // 进入容器
    2. [root@localhost ~]# docker exec -it mysql bash
    3. // 移除时间文件
    4. root@b7238f2a5cef:/# rm /etc/localtime
    5. // 挂载系统时间文件到容器
    6. root@b7238f2a5cef:/# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    7. root@b7238f2a5cef:/# exit
    8. exit
    9. // 重启容器
    10. [root@localhost ~]# docker restart mysql
    11. mysql
    12. // 查看时间
    13. [root@localhost ~]# docker exec -it mysql bash
    14. root@b7238f2a5cef:/# date
    15. Thu Aug 4 10:50:29 CST 2022

  • 相关阅读:
    ssprompt:一个LLM Prompt分发管理工具
    搜索引擎Elasticsearch基础与实践
    Python吴恩达深度学习作业23 -- 机器翻译(NMT)
    布隆过滤器简单实现添加和判断功能
    6.eureka服务发现实例(springcloud)
    [Rust] 动态分发的特征对象(&dyn trait / Box<dyn trait>)
    007.iSCSI服务器CHAP双向认证配置
    提高生产力!这10个Lambda表达式必须掌握,开发效率嘎嘎上升!
    算法:归并排序的用处
    springboot毕设项目城市轨道交通线路查询p2df3(java+VUE+Mybatis+Maven+Mysql)
  • 原文地址:https://blog.csdn.net/weixin_42280959/article/details/126155494
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号