MySQL Database connection from node js application

preview_player
Показать описание
In This video I have shown how to connect MySQL database from node js Application.

1. create node project "npm init -y"
2. install mysql package "npm install mysql"
4. import mysql package "const { createPool } = require('mysql')"
5. create pool connection
-----------------------------------------
const pool = createPool({
host: "localhost",
user: "root",
password: "",
database: "test",
connectionLimit: 10
})
6. execute query
---------------------------
if (err) {
}
})
Рекомендации по теме
Комментарии
Автор

Thank you sir. It took me an hour of adjusting with ports to make it work. Thank you for the tutorial.

elkhanhamet
Автор

Thanks man, you don't know how much i appreciate these kind of tutorials!!

Sac-chan
Автор

This has been the easiest and the best I have watched thank you for this

cmtg
Автор

Thank you so much, you deserve more subs!

victorivanov
Автор

thank you very much, it worked . I was struggling to connect it but my struggle ends here, once again thanks.

vishwajeetpatel
Автор

Thank you for this video, very useful for solving this issue and connecting mysql to node js.

riviannews
Автор

thanks for the tutorial.. I have one doubt do we need to end the connection if we are using the pool connection. If yes when do we do that???

nirajbadaik
Автор

Very helpful for beginners, Thank you so much

parkvince
Автор

thank you so much sir Was indeed helpful.

_aergul__
Автор

Very useful for beginners, thanks for making bro ❤️

heyazhar
Автор

thank you very much. this help me very much

mr.awexmen
Автор

when i run sql files in vscode terminal mysql> source schema.sql; it give this error
ERROR:
Failed to open file 'schema.sql', error: 2
Please help me

Irfanmalik-eh
Автор

how to give data to data base from the website

satyambansal
Автор

Also show us that from where we have to create the database

saifalikhan
Автор

Are we able to fetch data from MySQL database in Html table without API. Like in PHP we able to fetch data in HTML table without api using PHP loop. Could we do that same using node?? Or API is compulsory to show data with node js??

shahriarsblog
Автор

What happened when multiple query executed ? I mean How many connection established to DB Server in multiple query execution ?

rahim
Автор

Hello, In the same way I run the code but it showing something access denied error, could you please give explanation to this please,

throw err; // Rethrow non-MySQL errors
^

Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
at Sequence._packetToError
at Handshake.ErrorPacket
at Protocol._parsePacket
at Parser._parsePacket
at Parser.write
at Protocol.write
at Socket.<anonymous>
at Socket.<anonymous>
at Socket.emit (node:events:513:28)
at addChunk

at Protocol._enqueue
at Protocol.handshake
at PoolConnection.connect
at Pool.getConnection
at Object.<anonymous>
at Module._compile
at Module._extensions..js
at Module.load
at Module._load
at [as runMain] {
code: 'ER_NOT_SUPPORTED_AUTH_MODE',
errno: 1251,
sqlMessage: 'Client does not support authentication protocol requested by server; consider upgrading MySQL client',
sqlState: '08004',
fatal: true
}

yarramneediravindraswamy
Автор

Uncaught ReferenceError: require is not defined. Why is this happening? Everytime I use require in JavaScript I am stuck with this error.

SteveMorrow
Автор

The system cannot find the path specified. why am i getting this?

ruturajkulkarni
Автор

When I type node .\database.js
It gives me
Code : 'ER_NOT_SUPPORTED_AUTH_MODE',
errno: 1251
sqlMessage: 'Client does not support authentication protocol requested by server; consider upgrading MySQL client',
sqlState: '00004',
fatal: true
}

theraildynasty_