Error: ER_BAD_DB_ERROR: Unknown database In nodejs

By | December 29, 2017

Usually the below error will generate because of unknown db name or database is not yet created
Error: ER_BAD_DB_ERROR: Unknown database ‘node_dbs’
at Handshake.Sequence._packetToError (E:\project\vasanthan\node_modules\mysql\lib\protocol\sequences\Sequence.js:52:14)
at Handshake.ErrorPacket (E:\project\vasanthan\node_modules\mysql\lib\protocol\sequences\Handshake.js:130:18)
at Protocol._parsePacket (E:\project\vasanthan\node_modules\mysql\lib\protocol\Protocol.js:279:23)
at Parser.write (E:\project\vasanthan\node_modules\mysql\lib\protocol\Parser.js:76:12)
at Protocol.write (E:\project\vasanthan\node_modules\mysql\lib\protocol\Protocol.js:39:16)
at Socket. (E:\project\vasanthan\node_modules\mysql\lib\Connection.js:103:28)
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)

Solution:Please check the database name in phpmyadmin,if db is not there create a database.