6

I am trying to setup sequelize as ORM for my MariaDB.

Here is my setup:

var sequelize = require('sequelize');

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

When I run my app I get the following error :

/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

Why is sequelize trying to connect to mysql rather than mariadb as I specified in the dialect directive? Am I missing something?

Aaron Ullal
  • 4,855
  • 8
  • 35
  • 63

5 Answers5

9

Sequelize now has the dialect mariadb, do not use mysql

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

Sequelize connection code...

var sequelize = new Sequelize('database', 'username', 'password', {
  dialect: 'mariadb'
})
buycanna.io
  • 1,166
  • 16
  • 18
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
Gonzalo Bahamondez
  • 1,371
  • 1
  • 16
  • 37
3

What the previous answer fails to mention is you must also set the dialect to MySQL...dialect: mysql because dialect: mariadb does not exist.

buycanna.io
  • 1,166
  • 16
  • 18
0

You must install mysql or any dialect using -g.

npm i -g mysql
0

If you are using yarn:

yarn add mariadb
Eli Zatlawy
  • 678
  • 10
  • 24