最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - MariaDB connection with Sequelize - Stack Overflow

programmeradmin0浏览0评论

I have been checking for the connectivity of MariaDB, with Sequelize.

const Sequelize = require('sequelize');

// Setting up database (MariaDB) connection
const sequelize = new Sequelize('dbName', 'usr', 'pass', {
  host: 'localhost',
  dialect: 'mariadb'
});

But I am getting the following error:

/home/lt-196/api/node_modules/sequelize/lib/sequelize.js:236
        throw new Error('The dialect ' + this.getDialect() + ' is not supported. Supported dialects: mssql, mysql, postgres, and sqlite.');
        ^

Error: The dialect mariadb is not supported. Supported dialects: mssql, mysql, postgres, and sqlite.
    at new Sequelize (/home/lt-196/api/node_modules/sequelize/lib/sequelize.js:236:15)
    at Object.<anonymous> (/home/lt-196/api/app.js:21:19)
    at Module._pile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

I have been checking for the connectivity of MariaDB, with Sequelize.

const Sequelize = require('sequelize');

// Setting up database (MariaDB) connection
const sequelize = new Sequelize('dbName', 'usr', 'pass', {
  host: 'localhost',
  dialect: 'mariadb'
});

But I am getting the following error:

/home/lt-196/api/node_modules/sequelize/lib/sequelize.js:236
        throw new Error('The dialect ' + this.getDialect() + ' is not supported. Supported dialects: mssql, mysql, postgres, and sqlite.');
        ^

Error: The dialect mariadb is not supported. Supported dialects: mssql, mysql, postgres, and sqlite.
    at new Sequelize (/home/lt-196/api/node_modules/sequelize/lib/sequelize.js:236:15)
    at Object.<anonymous> (/home/lt-196/api/app.js:21:19)
    at Module._pile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
Share Improve this question edited Aug 2, 2018 at 12:47 Harshal Yeole 5,0011 gold badge23 silver badges43 bronze badges asked Aug 2, 2018 at 12:25 Sagar RajkuleSagar Rajkule 431 gold badge1 silver badge4 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

MariaDB For MariaDB patibility you have to install the package [email protected], or higher. The configuration needs to look like this:

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

Or Try this:

MariaSQL: https://www.npmjs./package/mariasql

A node.js binding to MariaDB's non-blocking (MySQL-patible) client library.

var Client = require('mariasql');

var c = new Client({
  host: '127.0.0.1',
  user: 'foo',
  password: 'bar'
});

c.query('SHOW DATABASES', function(err, rows) {
  if (err)
    throw err;
  console.dir(rows);
});

c.end();

MariaSQL is remended.

https://github./MariaDB/mariadb-connector-nodejs

NPM

    npm install --save mariadb
    npm install --save sequelize@next

Yarn

    yarn add mariadb
    yarn add sequelize@next
  const Sequelize = require('sequelize'),
    sequelize = new Sequelize(process.env.db_name, process.env.db_user, process.env.db_pass, {
    dialect: 'mariadb',
    dialectOptions: {
      socketPath: process.env.db_socket,
      timezone: process.env.db_timezone
    },
    pool: {
      min: 0,
      max: 5,
      idle: 10000
    },
    define: {
      charset: 'utf8',
      timestamps: false
    },
    benchmark: false,
    logging: false
  })
发布评论

评论列表(0)

  1. 暂无评论