How To Use MySQL with NodeJS

Hey what is up everyone, today we are looking at using MySQL and NodeJS to work with and store data in our NodeJS apps. This is a very simple tutorial aim toward programmers using Node and want to connect their app to a MySQL database instance. In this video we will build a very basic API to create and read posts from a MySQL database.
Hope you enjoy this video! Let me know by giving this video a thumbs up and subscribing for more content coming soon.
THANKS FOR 5K SUBS PEOPLE YOU ARE AMAZING NEVER SAW THIS COMING!💙
Video Links
==========
MySQL
dev.mysql.com/downloads/
NodeJS
nodejs.org/en/download/
Visual Studio Code
code.visualstudio.com/
mysql2
www.npmjs.com/package/mysql2
sequelize
sequelize.org/
GitHub Links are in the first PINNED comment!
My personal website
=================
www.thefullstackjunkie.com
Join my discord channel 🤓✌
/ discord
Timestamps
===========
00:00 Intro
00:52 Technologies walkthrough
04:00 Cloning Starter files
04:40 Folder walkthrough
07:53 MySQL Workbench Create New Database
14:00 Connecting Node with MySQL Database
18:30 Testing first SQL query from Node
21:00 Building out rest of little API
27:52 Building Post Model to use MySQL connection pool
45:11 Testing out final routes of API
47:35 Outro

Пікірлер: 116

  • @historianooficialunofficia2085
    @historianooficialunofficia20852 жыл бұрын

    about a year and a half ago i started learning Html , Css, Javascript, now i got hired as a React Native dev, im thanking all my learning channels. This is one of the best, keep the good work, and thanks, man!

  • @the_full_stack_junkie

    @the_full_stack_junkie

    2 жыл бұрын

    Congratulations champ

  • @danko5678

    @danko5678

    2 жыл бұрын

    inspiring

  • @hexparadusyoutube7428

    @hexparadusyoutube7428

    Жыл бұрын

    Any advice on how to get a remote software Job?

  • @historianooficialunofficia2085

    @historianooficialunofficia2085

    Жыл бұрын

    @@hexparadusyoutube7428 i just upload a profile in LinkedIn and in the third interview got the job

  • @hexparadusyoutube7428

    @hexparadusyoutube7428

    Жыл бұрын

    @@historianooficialunofficia2085 Is it a remote one and did you apply by 'Easy Apply' on LinkedIn or was it a regular Apply?

  • @zeiadtolba8601
    @zeiadtolba8601 Жыл бұрын

    To be honest, I'm astonished by how well you explain everything. I'm speechless. Great work!

  • @vijendra1150
    @vijendra11502 жыл бұрын

    Literally Awesome explaination.🙌🙌

  • @stefanmasic1287
    @stefanmasic1287 Жыл бұрын

    Dear my FSJ. Thank you 1.000.000.000 times. This is my first video after many try/catch in Node world. It works also for me. Incredible. Thank you very much for sharing your knowledge. Best regards, Štefan.

  • @peterkabiru5144
    @peterkabiru5144 Жыл бұрын

    Thank you so much, You made the whole process seamless to follow along as I practice

  • @saidmaroc8448
    @saidmaroc84483 жыл бұрын

    I just discovered your channel, and it's fantastic. continue, and thank you

  • @sportzone_
    @sportzone_ Жыл бұрын

    Keyboard tips are so cool man, thank you for that 😊

  • @nicetomeetugaming7024
    @nicetomeetugaming70242 жыл бұрын

    Amazing video, thanks sir!

  • @user-jp8dc1ew3c
    @user-jp8dc1ew3c8 ай бұрын

    Thank you. This was quite helpful. Straight forward.

  • @the_full_stack_junkie
    @the_full_stack_junkie3 жыл бұрын

    Starter files: github.com/LloydJanseVanRensburg/Node-Express-starter Ending files: github.com/LloydJanseVanRensburg/Node-MySQL-Tut

  • @ashushimpi2163

    @ashushimpi2163

    Жыл бұрын

    Thanks

  • @jsaentertaining8362
    @jsaentertaining8362 Жыл бұрын

    Absolutely incredible tutorial. I've been a professional dev for 4 years and I'm working on migrating some legacy code. Even though I was planning on skimming to just see package use and connection details I ended up sitting through the whole thing. very well done!

  • @TimurSevimli
    @TimurSevimli Жыл бұрын

    Thank you sir!🥸

  • @drpwnage23
    @drpwnage23 Жыл бұрын

    Thank you so much for this tutorial. You did an excellent job explaining things.

  • @the_full_stack_junkie

    @the_full_stack_junkie

    Жыл бұрын

    Glad it was helpful!

  • @user-bb6sb7if2u
    @user-bb6sb7if2u2 ай бұрын

    This video helped me so much thank you

  • @dagimcherinet1856
    @dagimcherinet18562 жыл бұрын

    Thank you very much, its really helpful for my project

  • @tushar_kushwaha
    @tushar_kushwaha3 жыл бұрын

    You are making my full stack journey amazing. Please try to upload videos frequently.

  • @muneebkhan1268
    @muneebkhan12682 жыл бұрын

    Great Content😀

  • @user-lm4fu7st5i
    @user-lm4fu7st5i9 ай бұрын

    thank you so much. excellent work

  • @eurlyswilsonfrometa2688
    @eurlyswilsonfrometa26882 жыл бұрын

    Thank you greetings from 🇨🇺

  • @pratikmusmade5422
    @pratikmusmade54222 жыл бұрын

    Thank you Sir for this wonderful Tutorial .I did not Know how to use oop concept in developing rest api . The code was just beautiful . Thank you ❣️❣️❣️

  • @hamzaseif4992
    @hamzaseif49922 жыл бұрын

    Good tutorial thank you sir

  • @malikabdullah7709
    @malikabdullah77092 жыл бұрын

    Thanks for these amazing videos. From nothing to be able to build my University project. I learned everything from your videos.

  • @the_full_stack_junkie

    @the_full_stack_junkie

    2 жыл бұрын

    Awesome so glad it helped

  • @malikabdullah7709

    @malikabdullah7709

    2 жыл бұрын

    @@the_full_stack_junkie Yes, It really helped me, even I still watch your videos when I stuck somewhere.

  • @praneethreddy9290
    @praneethreddy92903 жыл бұрын

    This channel is really a gem!! Thank you sir for all the knowledge transfer 🤩🙌

  • @the_full_stack_junkie

    @the_full_stack_junkie

    3 жыл бұрын

    Thanks for your positivity really do appreciate it🙏🤓

  • @bobcailu8849
    @bobcailu88492 жыл бұрын

    🇲🇫 This is a beautiful, simple and clear tutorial as well as the well-established MVC architecture. Thank you very much for everything and especially good luck we will be there to follow you.

  • @the_full_stack_junkie

    @the_full_stack_junkie

    2 жыл бұрын

    Thanks so much champ, very glad you found it helpful.

  • @mikhailshamshidov3148
    @mikhailshamshidov31489 ай бұрын

    great video!!!!

  • @UsmanArain
    @UsmanArain2 жыл бұрын

    much helpfull sir!

  • @saybers-4516
    @saybers-4516 Жыл бұрын

    Thank you the video is so good

  • @mickaelrichard7255
    @mickaelrichard72553 жыл бұрын

    Thanks you so much I really needed a refresher :) Maybe a bigger project using mysql or an Orm would be great to follow :)

  • @the_full_stack_junkie

    @the_full_stack_junkie

    3 жыл бұрын

    Will do

  • @ashish_prajapati_tr
    @ashish_prajapati_tr2 жыл бұрын

    11k subs completed.👍👍👍

  • @the_full_stack_junkie

    @the_full_stack_junkie

    2 жыл бұрын

    Thanks for the support will give you shout out in next video.

  • @SubarnamIyer
    @SubarnamIyer Жыл бұрын

    great video sir cleared all of my consfusions about promises

  • @the_full_stack_junkie

    @the_full_stack_junkie

    Жыл бұрын

    Glad it helped

  • @ashishkhanal5672
    @ashishkhanal56722 жыл бұрын

    You are always awesome thank you mate..... Hoping to see image upload in this video....

  • @determ4675
    @determ46753 жыл бұрын

    Not gonna watch it now but I benefitted so much for the shopping cart mern tutorial video that I just wanted to drop by and leave a like and a comment ASAP :D

  • @the_full_stack_junkie

    @the_full_stack_junkie

    3 жыл бұрын

    Thanks man. Just showing of the basics here nothing much just wanne show what I learned recently✌🤓 but thanks for the comment! And like

  • @abdulkadirguven1173
    @abdulkadirguven11732 жыл бұрын

    Thank you ;)

  • @ranasaani
    @ranasaani Жыл бұрын

    Thanks dear.

  • @trodoumanian5135
    @trodoumanian5135 Жыл бұрын

    Thank You

  • @Strelok473
    @Strelok4737 ай бұрын

    Great tutorial if you have some experience with this from before, but very tough if you're new.

  • @arupde6320
    @arupde63202 жыл бұрын

    good job .. keep uploading ...

  • @the_full_stack_junkie

    @the_full_stack_junkie

    2 жыл бұрын

    Thanks man Reddit Clone (React, Redux Toolkit, Node, MySQL) coming soon

  • @mohamedyoussef8835
    @mohamedyoussef8835 Жыл бұрын

    Awesome video ++++++++++++ 🙂🙂

  • @felicianvass4545
    @felicianvass4545 Жыл бұрын

    Great tutorial, thanks. Just one question. Is it not neccesarry to release / close the connection after db.execute(sql) ? Or is it handled in this case automaticly?

  • @tianxiao9233
    @tianxiao92332 жыл бұрын

    love

  • @dilanperera4529
    @dilanperera4529 Жыл бұрын

    I'm also follow this kind of coding pattern from MVC. it's more maintainable. but what i'm thinking is, it may occur some memory leak issue because it just create new instance from Post model but not reuse any of instance. when we get ORM every ORM has some caching mechanism for reuse previous created instance.

  • @mohammedimran-rj8tl
    @mohammedimran-rj8tl2 жыл бұрын

    Can you also add update and delete operations?

  • @blah9960
    @blah99602 жыл бұрын

    Hey please make video on mysqul series.

  • @lightcode6487
    @lightcode6487 Жыл бұрын

    Question: do I need to use workbench or can I also use phpmyadmin without having to change any code? Nice video!

  • @TomJerry-bp9ig
    @TomJerry-bp9ig3 жыл бұрын

    🌻

  • @edinburghrules
    @edinburghrules3 жыл бұрын

    Awesome! I learned node and mongo thanks to you. How do you like mongodb compared to SQL?

  • @the_full_stack_junkie

    @the_full_stack_junkie

    3 жыл бұрын

    MongoDB is much easier to work with in my opinion. Structuring your data is easier to understand most of the time. But again I have used and still use both. For some the one is better choice than the other. For me I would still give mongodb the lead specially when working with the rest of the JavaScript stack (MERN, MEVN, MEAN).

  • @edinburghrules

    @edinburghrules

    3 жыл бұрын

    @@the_full_stack_junkie Yeah, I felt MongoDB was very intuitive, coming from frontend React and using Firebase. I see a lot more job postings for SQL however, so really appreciate you posting this video. Thanks! :D

  • @the_full_stack_junkie

    @the_full_stack_junkie

    3 жыл бұрын

    Always good to know SQL its not going anywhere. Glad you found the video insightful. More videos coming soon.

  • @blah9960
    @blah99602 жыл бұрын

    Hey i want video on hooks. Please make a one video on this

  • @sachinnishad88
    @sachinnishad882 жыл бұрын

    please continue mongodb series 🥺🥺

  • @divertissement2866
    @divertissement2866 Жыл бұрын

    Hello thank you for this wandeful tuto.But i have this error during registration: TypeError: Post is not a constructor. How can i salve this please ?

  • @NotMyAlt6969
    @NotMyAlt696910 ай бұрын

    good tutorial, the volume cud be louder

  • @muhammadhassannoman4907
    @muhammadhassannoman4907 Жыл бұрын

    i am having axios api issue in react native app, the axios api works fine in postman but not in the app, it send {} body to server.

  • @Rahul-ur6xz
    @Rahul-ur6xz2 жыл бұрын

    Which Theme You Use in Vs Code Editor

  • @hugonatan9817
    @hugonatan98173 жыл бұрын

    SUBSCRIBED. GREAT CHANNEL, THANK YOU FOR THE AMAZING CONTENT🙌 (please if you have a change make a PRISMA & GRAPHQL tutorial, that would be awesome)

  • @jamest4027
    @jamest40272 жыл бұрын

    when you deploy your backend, what do you put in process.env.DB_HOST...obviously it is not localhost anymore

  • @romimaximus
    @romimaximus3 жыл бұрын

    i wish you could turn you mic volume up, cause right now my volume is at 100%, and i can barelly hear your voice....but besides that that this is a awesome great tutorial, thank you 😎👍

  • @the_full_stack_junkie

    @the_full_stack_junkie

    3 жыл бұрын

    Ooo wow thanks man will definitely turn it up next time didnt know it was to soft my bad. Glad you found it helpful

  • @xtech5881
    @xtech58812 жыл бұрын

    Sir, can we stop connection after connection because for aws always needs to start server. How i do it. Please give hint by syntax..where i destroy the query and how to add prod database user name and password..if u reply soon that helps me alot..and for this video realy realy awesome..

  • @aroabdulazeez76
    @aroabdulazeez768 ай бұрын

    it's what i was looking for but i don't understand what we have to manually create the database and table instead of just doing it with mysql2

  • @viralbanks4703
    @viralbanks47033 жыл бұрын

    Bro when will e-commerce tutorials be on page

  • @abelmarkos5753
    @abelmarkos57533 жыл бұрын

    Can you do some MERN Social media app

  • @danianiazi8229
    @danianiazi82292 жыл бұрын

    Waiting for Nodejs with postgress 👀

  • @aeciofilho7256
    @aeciofilho7256 Жыл бұрын

    wich web server can I use to node.js and mysql?

  • @user-rg7jg8fc1h
    @user-rg7jg8fc1h Жыл бұрын

    Hello! How i can use transactions?

  • @masteremerald2592
    @masteremerald25924 ай бұрын

    Hello, Thank you so much for the video but just a quick question, if you are hosting your database locally would that mean your computer has to be running 24/7 If you plan on using this database for a live website?

  • @the_full_stack_junkie

    @the_full_stack_junkie

    4 ай бұрын

    Yes you will need to keep you computer on

  • @SixtyNeptune
    @SixtyNeptune2 жыл бұрын

    do you make model and controller for each one and one, for example users , posts, etc...

  • @the_full_stack_junkie

    @the_full_stack_junkie

    2 жыл бұрын

    So the models are made to represent the schema of the table in the database. And the controllers are then made to use the models and work with the database. So you can see it as such that a controllee can be for example for each one of the entities (posts, comments, users etc). But this in not always the case you can make controller methods for different things. But the controllers job is to work with the models and do some business logic

  • @DeepakGupta-pz4fx
    @DeepakGupta-pz4fx3 жыл бұрын

    Sir please make on one video microservices node js tutorial

  • @the_full_stack_junkie

    @the_full_stack_junkie

    3 жыл бұрын

    Hey man I am not really familiar with microservices, yet. I have done one course on it but I hasn't been something I have been actively working with. Would really recoomend checking out udemy, stephan grinders course on microservices in nodejs.

  • @sayedhurhussain4092
    @sayedhurhussain4092 Жыл бұрын

    please upload update api

  • @PFE-gx2kv
    @PFE-gx2kv2 жыл бұрын

    heyy can someone help me to fix that error # - access denied for user 'root'@'localhost' (using password no)

  • @divyanshusah2809
    @divyanshusah28092 жыл бұрын

    In ur ecommerce series there is no search feature.😕

  • @smitpanchal
    @smitpanchal Жыл бұрын

    which color theme do you have for vs code?

  • @the_full_stack_junkie

    @the_full_stack_junkie

    Жыл бұрын

    Cobalt

  • @FK-rt9bt
    @FK-rt9bt2 жыл бұрын

    how do you the Updating part. static update(vorname, nachname, id) { let sql = `UPDATE Anbieter SET vorname = ${vorname}, nachname = ${nachname} WHERE Anbieter_id= ${id};`; return db.execute(sql); } this isn't working

  • @duyennt1351

    @duyennt1351

    2 жыл бұрын

    I'm looking forward to the update. I have code but it error in postman exports.updatePostById = async (req, res, next) => { try { let { title, body } = req.body; let postId = req.params.id; let [post, _] = await Post.updatearticlebyid(postId, title, body); res.status(200).json({ post: post[0] }); } catch (error) { console.log(error); next(error); } };

  • @maelstrom57
    @maelstrom572 жыл бұрын

    34:31 That would be a very poor practice in production. You're supposed to escape the values to prevent SQL injections: VALUES (?, ?, ?) and pass the actual values into the `execute` method: await pool.execute(sql, [this.title, this.body, createdAtDate]);

  • @benzemamumba

    @benzemamumba

    2 жыл бұрын

    No doubt, this is only a proof of concept buddy. No need to be pedantic about things.

  • @Startthecode-my1tv
    @Startthecode-my1tv8 ай бұрын

    everything is good but why audio is so down?

  • @rahulsaini5503
    @rahulsaini55032 жыл бұрын

    what is the dotenv module?

  • @the_full_stack_junkie

    @the_full_stack_junkie

    2 жыл бұрын

    Basically helps us set env variable in our node app. Gives us access to process.env.

  • @user-lu9lx3xf4q
    @user-lu9lx3xf4q5 ай бұрын

    github link?

  • @_Greenflag_
    @_Greenflag_2 ай бұрын

    Some nice SQL injections if you push this code to production.

  • @shaharyarahmed2178
    @shaharyarahmed21782 жыл бұрын

    where is the git clone link ?

  • @the_full_stack_junkie

    @the_full_stack_junkie

    2 жыл бұрын

    The post comment at the top.

  • @nallaiahkalis4224

    @nallaiahkalis4224

    Жыл бұрын

    @@the_full_stack_junkie not there

  • @brickstv3156

    @brickstv3156

    4 ай бұрын

    @@the_full_stack_junkie its not there bro

  • @alainportant6412
    @alainportant6412 Жыл бұрын

    It's quite unusual to hear about NodeJS & MySQL being used together. Why are all these people using it with Mongo DB ? Just a trend ?

  • @the_full_stack_junkie

    @the_full_stack_junkie

    Жыл бұрын

    Nodejs can be used with almost any db. Mongodb just has a very populate syntax which is JS like so just keeps things lookin like JS.

  • @ljlinen
    @ljlinen6 ай бұрын

    i can hear a mzansi accent...?....?....? ❤❤

  • @the_full_stack_junkie

    @the_full_stack_junkie

    6 ай бұрын

    Fo sho 🤙🏼

  • @KnarikGhazaryan
    @KnarikGhazaryan Жыл бұрын

    The official way to pronounce MySQL is My Ess Que Ell, not My Sequel.