错误:无法识别编码:尝试 Sequelize Mysql 时“未定义”

问题描述 投票:0回答:2

我正在尝试在我的 Ubuntu 服务器上安装并运行 Blocktogether

当我跑步时

./node_modules/.bin/sequelize --config=config/sequelize.json db:migrate --env=production

我收到此错误:

Sequelize CLI [节点:12.22.9,CLI:5.5.1,ORM:5.22.5]

已加载配置文件“config/sequelize.json”。

使用环境“生产”。

== 20160117144545-init:正在迁移=======

查询:/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */

查询:

/*!40101 设置@OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */

查询:

/*!40101 设置@OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */

查询:

/*!40101 设置名称 utf8 */

查询:

/*!40103 设置@OLD_TIME_ZONE=@@TIME_ZONE */

错误:无法识别编码:“未定义”(搜索为:“未定义”)

在 Object.getCodec (/etc/blocktogether/node_modules/mysql2/node_modules/iconv-lite/lib/index.js:106:23)

在 Object.getEncoder (/etc/blocktogether/node_modules/mysql2/node_modules/iconv-lite/lib/index.js:117:23)

在Object.exports.encode(/etc/blocktogether/node_modules/mysql2/lib/parsers/string.js:23:25)在Query.toPacket(/etc/blocktogether/node_modules/mysql2/lib/packets/query.js) :16:30)

在 Query.start (/etc/blocktogether/node_modules/mysql2/lib/commands/query.js:55:38)

在 Query.execute (/etc/blocktogether/node_modules/mysql2/lib/commands/command.js:39:22)

在 Connection.handlePacket (/etc/blocktogether/node_modules/mysql2/lib/connection.js:408:32)

在 Connection.addCommand (/etc/blocktogether/node_modules/mysql2/lib/connection.js:430:12)

在 Connection.query (/etc/blocktogether/node_modules/mysql2/lib/connection.js:493:17)

在/etc/blocktogether/node_modules/sequelize/lib/dialects/mysql/query.js:60:20

在 Promise._execute (/etc/blocktogether/node_modules/bluebird/js/release/debuggability.js:384:9)

在 Promise._resolveFromExecutor (/etc/blocktogether/node_modules/bluebird/js/release/promise.js:518:18)

在新的 Promise (/etc/blocktogether/node_modules/bluebird/js/release/promise.js:103:10)

在 Query.run (/etc/blocktogether/node_modules/sequelize/lib/dialects/mysql/query.js:39:12)

在 /etc/blocktogether/node_modules/sequelize/lib/sequelize.js:655:29

在 tryCatcher (/etc/blocktogether/node_modules/bluebird/js/release/util.js:16:23)

在 Promise._settlePromiseFromHandler (/etc/blocktogether/node_modules/bluebird/js/release/promise.js:547:31)

在 Promise._settlePromise (/etc/blocktogether/node_modules/bluebird/js/release/promise.js:604:18)

在 Promise._settlePromise0 (/etc/blocktogether/node_modules/bluebird/js/release/promise.js:649:10)

在 Promise._settlePromises (/etc/blocktogether/node_modules/bluebird/js/release/promise.js:729:18)

在 _drainQueueStep (/etc/blocktogether/node_modules/bluebird/js/release/async.js:93:12)

在 _drainQueue (/etc/blocktogether/node_modules/bluebird/js/release/async.js:86:9)

我的sequelize.json 包含这些行:

{
   "development": {
     "username": "root",
     "password": "Password",
     "database": "Twitter",
     "host": "127.0.0.1",
     "dialect": "mysql"
   },
   "production": {
     "username": "root",
     "password": "Password",
     "database": "Twitter",
     "host": "127.0.0.1",
     "dialect": "mysql"
 
   }
 }

您能帮我解决这个错误吗?

jquery mysql node.js ubuntu sequelize.js
2个回答
1
投票

我通过删除 sql 文件中以 /*!40.. 开头的所有行解决了这个问题。


0
投票

在顶部的 SQL 文件中有

/*!40101 SET NAMES utf8 */;
/*!40101 SET NAMES utf8mb4 */;

删除

/*!40101 SET NAMES utf8 */;
,它开始工作

© www.soinside.com 2019 - 2024. All rights reserved.