使用MariaDB的Sequelize错误

时间:2016-03-04 13:11:00

标签: node.js sequelize.js mariadb mariasql

我正在为sequelize设置MariaDB作为ORM。

这是我的设置:

var sequelize = require('sequelize');

var db= new sequelize('dbname', 'user', 'pass', {
  dialect: 'mariadb'
});

当我运行我的应用时,我收到以下错误:

/my/path/to/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:23
    throw new Error('Please install mysql package manually');
    ^

Error: Please install mysql package manually

为什么sequelize试图连接到mysql而不是像我在dialect指令中指定的mariadb?我错过了什么吗?

4 个答案:

答案 0 :(得分:5)

Sequelize internally uses the same library to connect with MariaDB or MySQL , take a look to the documentation http://docs.sequelizejs.com/en/latest/docs/getting-started/ specifically in the section Installation.

To make it works you just need to install mysql package so:

$ npm install --save mysql2

答案 1 :(得分:2)

上一个答案没有提到的是,您还必须将方言设置为MySQL ... dialect: mysql,因为dialect: mariadb不存在。

答案 2 :(得分:0)

Sequelize现在拥有方言mariadb,请勿使用mysql

npm install --save mariadb
npm install --save sequelize

确定连接代码...

var sequelize = new Sequelize('database', 'username', 'password', {
  dialect: 'mariadb'
})

答案 3 :(得分:0)

您必须使用-g安装mysql或任何方言。

ap