2
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

3 Answers 3

11

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

Sign up to request clarification or add additional context in comments.

1 Comment

god bless u achinu :)
0

If you use the command "sequelize init" to init the project,then you should check your config.json.Because by default "port" field don't include. Meanwhile,please make sure your config.json does not contain any unquoted like the password in this example.

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

Comments

0

In my case, I had an empty object in my database.json file:

{
  "dev": {
    "driver": "pg",
    "user": {"ENV": "DB_USER"},
    "password": {"ENV": "DB_PASS"},
    "host": {"ENV": "DB_HOST"},
    "database": {},              <-- THIS LINE
    "port": {"ENV": "DB_PORT"}
  }
}

The line: "database": {}, was causing the issue.

"database" should be a string.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.