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?

5 Answers 5

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'
})
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
3
  • I went through the docs a bazillion times...don't know how I didn't see that...thank you!! Mar 4, 2016 at 18:23
  • 1
    mysql2 required for current versions
    – Len
    Jun 7, 2018 at 12:55
  • @indospace.io If the answer is incorrect in your opinion either say so in the comments or post your own answer, but do not edit somebody else's answer.
    – Dharman
    Sep 12, 2019 at 10:56
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.

0

You must install mysql or any dialect using -g.

npm i -g mysql
0

If you are using yarn:

yarn add mariadb

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.