關於Mysql資料庫時間和查詢出來的時間不一致問題

2021-09-24 02:30:08 字數 820 閱讀 6793

資料庫記錄的時間

mybatis查詢出來的時間

createtime=2019-06-02 17:39:02.0, lastupdatedtime=2019-06-02 18:49:05.0
差了8小時。。。url用的是servertimezone=gmtspring.datasource.url=jdbc:mysql://localhost:3306/flashsale?usessl=false&characterencoding=utf8&servertimezone=gmtmysql使用的是與作業系統一致的

修改後的url

spring.datasource.url=jdbc:mysql://localhost:3306/flashsale?usessl=false&characterencoding=utf8&servertimezone=asia/shanghai

再次查詢就與資料庫的一致了

createtime=2019-06-02 09:39:02.0, lastupdatedtime=2019-06-02 10:49:05.0

關於MySQL資料庫如何按時間查詢

這裡做了幾個測試 select from simingpai where timestamp createtime 2015 9 6 select from simingpai where timestamp createtime 2015 9 6 00 00 00 select from simi...

MySQL資料庫 關於查詢 隨筆

select id,title,haha mark from course select from select from relation temp left join audio audio on audio.id temp.audio id order by temp.id desc批量更新條...

mysql 初級操作 查詢資料庫時間

然後在my.ini檔案中的 mysqld 下面一行新增 skip grant tables 加上這句話 1 最簡單的 create table t1 id int not null,name char 20 2 帶主鍵的 a create table t1 id int not null prima...