问题

Nodejs 工程下,用 sequelize 向一个现有的 MySQL 数据库中初始化数据时报错,如题:

original: Error: Unknown storage engine 'InnoDB'

ENV

  • MySQL 5.6
  • Sequelize: ^6.25.5

排查

  • 查看 mysql 配置 my.ini 中的默认引擎
# The default storage engine that will be used when create new tables when
default-storage-engine=MYISAM

The default engine for a model is InnoDB.

修改默认 engine

const sequelize = new Sequelize(db, user, pw, {
  define: { engine: 'MYISAM' }
});
  • 再次执行,回显
(node:1940) [SEQUELIZE0006] DeprecationWarning: This database engine version is not supported, please update your database server. More information https://github.com/sequelize/sequelize/blob/main/ENGINE.md
(Use `node --trace-deprecation ...` to show where the warning was created)

数据库不便升级,考虑 sequelize 是否可降级。实在不行,我只能重装升级 msqyl 了。

解决方案

  • 降级 sequelize 解决

cnpm i sequelize@^5

posted on 2022-11-21 00:07  死宅程序员  阅读(85)  评论(0编辑  收藏  举报