2

Currently I am trying different ORMs, and in between Sequelize.

I have an application in development that does not have any password for the root user, but this is for development, is it mandatory to add a password to the configuration to connect with Sequelize?

By command line I just do:

mysql -u root

and thats enough to get it up and running and play locally.

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
juan garcia
  • 1,326
  • 2
  • 23
  • 56

1 Answers1

3

It clearly depends on how you initialize the connection.

You can just declare the username as root and the password as null.

{
    "development": {
        "username": "root",
        "password": null,
        "database": "database_development",
        "host": "127.0.0.1",
        "dialect": "mysql"
    },
    "test": {
        "username": "root",
        "password": null,
        "database": "database_test",
        "host": "127.0.0.1",
        "dialect": "mysql"
   },
    "production": {
        "username": "root",
        "password": null,
        "database": "database_test",
        "host": "127.0.0.1",
        "dialect": "mysql"
   }
}

Now if you just instantiate a Sequelize object you can try skipping the password parameter entirely like below.

const Sequelize = require('sequelize');
const sequelize = new Sequelize('database', 'username', null, {
   host: 'localhost',
   dialect: 'mysql' | 'sqlite' | 'postgres' | 'mssql',
       operatorsAliases: false,
   pool: {
       max: 5,
       min: 0,
       acquire: 30000,
       idle: 10000
   },
}); 
sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
slysterous
  • 124
  • 2
  • I see your point, slysterous, although I tried this approach too, I get the error: Client does not support authentication protocol requested by server; consider upgrading MySQL client, and I am not entirely sure why I am having this error, may be a local configuration on my current mysql db... but not sure yet – juan garcia Oct 29 '18 at 14:20
  • Even more, I just got an error code: code: 'ER_NOT_SUPPORTED_AUTH_MODE', errno: 1251, sqlState: '08004', – juan garcia Oct 29 '18 at 14:24
  • 1
    Hmm what version of MySql are you using? This is not a Sequelize issue i believe. Also check this [link](https://stackoverflow.com/questions/49991865/node-js-mysql-error-1251-client-does-not-support-authentication-protocol) – slysterous Oct 29 '18 at 14:37
  • mysql Ver 8.0.12 for osx10.14 on x86_64 (Homebrew) just installed mysql – juan garcia Oct 29 '18 at 15:11
  • After taking a deeper look this morning into the DB I see that the credentials had some differences, and all is being supported, thx for your help – juan garcia Oct 30 '18 at 08:47