How to Connect Node js to MySQL Database and Fetch Data in 5 minutes

preview_player
Показать описание


My websites

Learn Programming by joining International Computer Programmers here:

Feel free to connect with me

Your support can help me improve my content:
Рекомендации по теме
Комментарии
Автор

תותח אלוףףףףףף
ההסבר ממש מעולה ועוזר
תודה!🙏

osleyfg
Автор

Hello Brother! Excellent Video, You just got a sub thank you so much. So simple and understandable. TY ❤❤

CorreaLobo
Автор

short video and to the point. great job

nerolifong
Автор

awesome. finally i can connect the two!!! woo yea!!! Thank you sir :)

williamdevonshire
Автор

For those getting undefined, I used this code to connect to the database

const mysql = require("mysql")

//Create a Database Connection

const con = mysql.createConnection({
host:'localhost',
user:'root',
password:'your_password',
database:'your_databse'
})

con.connect((err) => {
if(err)
{
console.log(err)
}else{
console.log("CONNECTION SUCCESSFUL!")
}
})

// Get The Data From The Table
con.query('select * from your_table', (err, res) =>{
return console.log(res)
})

MsamerieJohnson
Автор

At [02:39], I was at first thrown off by the destructuring syntax 
const
const pool = createPool( { … } ) ;
An equivalent (more pedestrian) alternative would be something like:
const mysql = require('mysql') ;
const pool = mysql.createPool( { …} )

LinXiaoChaun
Автор

Really useful video. By any chance, do you have a follow up video on how to post data to mysql work bench in javascript as well?

bryantgarcia
Автор

For me it keeps saying 'undefined'. 😭 Could you help out how to fix that issue? I have node.js installed and triple checked if my code looks the same like in video.. 😕

Sukubus
Автор

hey! great video. i have a question, if i want to deploy this website on vercel/heroku what I need to do? our sql data base located in localhost how correctly i understand so can we push it somewhere? something like cloud storage? thanks for the answer :3

assetdev
Автор

Thank you so much for this, great tutorial!

DiscussedFir
Автор

very useful, thank you for making the video

Sami_Ljimari
Автор

really good tutorial, just one question, how can i default select database name

_dejvy
Автор

Thanks! And then? When you want to upload proyect to prod? What do I have to do to hide this information?

michelsolis
Автор

Do we have to first create table insql

nimeshpatilvlogs
Автор

why didn't work on my visual studio code when I'll run in terminal? Pls. help!!

wildriftgames
Автор

Hey I have a error on require() function

SITPonrajA
Автор

Can uou show how to connect node express app to online MySQL database

goodluckoriuwa
Автор

Hi, i want to store the return of the query in a variable. how can i make that work? When i write const x = (query) and instead of return console.log() just returning the res. It doesn't gave me back the result. Can anyone help me how to get the res returned to store it in a variable?

leonbou
Автор

i applied your code but it just displays undefined what do i do?

tqelbfi
Автор

is require not defined anymore? i get "ReferenceError: require is not defined"

Maumau