mysql - Sequelize Node JS 中的时区问题

标签 mysql node.js sequelize.js mysql2

我已经使用 Node JS 构建了一个应用程序,并使用 sequelize ORM 与 mysql 连接

在配置 sequelize 时,我将时区提供为“欧洲/奥斯陆”,但在运行应用程序时,它给出了与 sequelize 使用的 mysql2 包相关的警告,如下所示
Ignoring invalid timezone passed to Connection: Europe/Oslo. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
仅供引用:从 3 月 29 日夏令时开始, 不能使用“+01:00”作为时区选项

任何人都可以帮我解决这个问题。

Sequelize 配置如下:

enter image description here

最佳答案

删除 collate 选项并根据您的时区传递 timezone '+08:00'。我测试了这个设置对我来说工作正常

const sequelize = new Sequelize(dbConfig.database, dbConfig.username, dbConfig.password, {
    "dialect": "mysql",
    "charset": "utf8mb4",
    "dialectOptions": {
      "useUTC": false
    },
    "logging": null,
    "timezone": "+00:00",
    "seederStorage": "sequelize",
    "operatorsAliases": false
});

关于mysql - Sequelize Node JS 中的时区问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60881457/

相关文章:

mysql - 无法使用 Sequelize 库连接三个具有 Sum 聚合函数的表

php - MySQL 表间自增

php - 如何创建不可预测的用户标识?

javascript - Grunt : minify js across project of multiple dirs, 以便每个目录的内容扁平化为单个缩小文件

node.js - 按关联模型排序时,Sequelize 抛出错误 "Unable to find a valid association for model x"

node.js - 有没有办法自动编码 where 子句中的属性,使其与模型 setter (sequelize)匹配?

Mysql如何从一个表中选择列值不是X和Y的所有记录

php - 收到以下错误 : Number of variables doesn't match number of parameters in prepared statement

javascript - javascript 中数组中值的匹配

node.js - Nestjs在Container Start上退出