Sequelize db:migrate throw TypeError: Data must be a string or a buffer

crypto.js:74
  this._handle.update(data, encoding);
               ^
TypeError: Data must be a string or a buffer
at TypeError (native)
at Hash.update (crypto.js:74:16)
at sha1 (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/auth_41.js:30:8)
at Object.token [as calculateToken] (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/auth_41.js:64:16)
at new HandshakeResponse (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/packets/handshake_response.js:25:24)
at ClientHandshake.sendCredentials (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/commands/client_handshake.js:46:27)
at ClientHandshake.handshakeInit (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/commands/client_handshake.js:122:10)
at ClientHandshake.Command.execute (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/commands/command.js:39:20)
at Connection.handlePacket (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/connection.js:417:28)
at PacketParser.onPacket (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/connection.js:93:16)
at PacketParser.executeStart (/mnt/projects/Nodejs/develda/node_modules/mysql2/lib/packet_parser.js:73:14)
at Socket.<anonymous> (/mnt/projects/Nodejs/develda/node_modules/mysql2 /lib/connection.js:101:29)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)

I'm getting this error when I try to migrate with node_modules/.bin/sequelize db:migrate

I think the mysql2 package causes this error

I'm appreciate for your help


First, please make sure your config.json does not contain any unquoted values like the password in this example:

{
 "my_env": {
    "username": "root",
    "password": 1234,
    "database": "my_db",
    "host"    : "localhost",
    "dialect" : "mysql"
  }
}

If that doesn't solve your problem and you have a strong reason to believe it has something to do with mysql2 package, try downgrading your sequelize package to v3 and which uses mysql rather than mysql2