Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequelize error with MariaDB

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?

like image 319
Aaron Ullal Avatar asked Dec 11 '22 18:12

Aaron Ullal


2 Answers

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'
})
like image 107
buycanna.io Avatar answered Dec 21 '22 22:12

buycanna.io


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
like image 27
Gonzalo Bahamondez Avatar answered Dec 21 '22 23:12

Gonzalo Bahamondez