Answer the question
In order to leave comments, you need to log in
Why is the connection to the database automatically disconnected?
const db = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '',
database: 'mydb'
});
db.connect((err) => {
if(err){
throw err;
}
console.log('MySql connected');
});
MySql connected
events.js:183
throw er; // Unhandled 'error' event
^
Error: Connection lost: The server closed the connection.
at Protocol.end (C:\Users\asik\Desktop\copy\node_modules\mysql\lib\protocol\Protocol.js:113:13)
at Socket.<anonymous> (C:\Users\asik\Desktop\copy\node_modules\mysql\lib\Connection.js:109:28)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question