Using MySQL With Node.js

Поделиться
HTML-код
  • Опубликовано: 15 ноя 2024

Комментарии • 457

  • @miriambonilla992
    @miriambonilla992 5 лет назад +34

    3 hours spend looking for an example of adding parameters at request, finally an example that works, really helpful

    • @apurv5847
      @apurv5847 3 года назад

      I need a help. So I made a login page which works fine when input is correct. But in case if the input goes wrong like either the password or username, it throws error and the server crashes. I don't want that. Instead I want that error to be handled someway but I ain't able to find any way. Please help me with this. I'd really appreciate if you can please.

  • @ismailhamdach2672
    @ismailhamdach2672 2 года назад +26

    00:00 Intro
    01:40 Install XAMPP
    03:09 Create app & Install dependencies
    07:03 Create connection
    08:12 Connect to MySql
    09:30 Create database
    12:36 Create table posts
    16:56 Insert data to posts
    19:58 Select posts
    21:10 Select single post
    23:05 Update post
    24:55 Delete post

  • @AtomDellow
    @AtomDellow 3 года назад +24

    I've gone through dozens of videos on this topic, I was finally able to get this going through this; you're very clear and concise. I mean, thanks to all the others for adding to my knowledge base, but it goes a long way to create a video where someone who can speak clearly and knows what they are doing, without wasting time.
    Thank you.

    • @MarshGames
      @MarshGames 2 года назад

      This is exactly what I think every time I want to learn something new. Brad is one of the few that is genuine, not overly and grossly enthusiastic, explains clearly, and is even funny at times which helps ease the learning process. He has a natural ability to make learning fun in this category.

    • @ismailhossain964
      @ismailhossain964 2 года назад

      True

  • @TraversyMedia
    @TraversyMedia  7 лет назад +102

    Guys I apologize for the out of sync mini-cam toward the middle/end. I'm working on fixing that in my recording software. Hope you enjoy the video!!

    • @simrandotdev
      @simrandotdev 7 лет назад +2

      Hi Brad, thanks for this video. I have a request in countinuation this video. I would be more than happy to pay for that course. A detailed course on Sequilize ORM for Node teaching basics of Sequilize and also Database Design using Sequilize. There are not much great resources on it and it would be great to have a course from you. Please consider this once :-)

    • @utna9337
      @utna9337 7 лет назад +2

      just came here to press a like, u deserve it man :) good job

    • @TraversyMedia
      @TraversyMedia  7 лет назад +3

      I will most likely do a youtube video but I am also considering a node.js course with a detailed project using sequelize

    • @TraversyMedia
      @TraversyMedia  7 лет назад +1

      Thank you bud :)

    • @simrandotdev
      @simrandotdev 7 лет назад

      Thanks

  • @ferdinandhriadel8100
    @ferdinandhriadel8100 3 года назад +7

    Thank you Brad. Why is it that you seem to be the only guy on the internet who can explain things so that they're easy to understand, easy to implement and don't waste your time? You helped me so much (with your Udemy courses and RUclips videos) I cannot thank you enough. You rock :)

  • @krishankumar8720
    @krishankumar8720 2 года назад +4

    no words for traversy media i cant imagine that much information in this duration very clearly explained hats off man from india

  • @WolfManThoughts
    @WolfManThoughts 4 года назад +5

    i regret not learning node backend development a few years ago, and sticked with laravel and codeigniter as the companies i was working for had projects in those. Thank you for this Brad. Your NodeJS Tutorials are very easy to get and understand. Thank You.

  • @matthewbrignola5510
    @matthewbrignola5510 Год назад

    Was just building an express mysql2 api just for fun to practice and forgot how to use "?" for escape characters in queries to prevent sql injection. Fast forwarded to 17:30 and got my answer. Thanks TraversyMedia. I am now a professional web dev working on a contract with the DoD and your RUclips channel really helped me to become the web developer that I am today.

  • @caybokotze
    @caybokotze 7 лет назад +21

    Every time I see this Traversy Media intro I know something good is coming...

  • @C4ssstiel
    @C4ssstiel 3 года назад +5

    Great video. I was coming from mssql and had to find this specific video on how to link node.js with MySQL. Spot on. Thanks for the video, really helpful and well executed. Simple and easy, no messing around.

  • @ankitaaarya
    @ankitaaarya 7 лет назад

    this is some of the channel on which i don't skip ads...for now this is the best i can do to help this channel. and i am commenting while that long ass ad is playing. :)

    • @TraversyMedia
      @TraversyMedia  7 лет назад +3

      That's plenty. Thank you. I know ads really suck. I do the same thing though for all the creators I watch and enjoy. Especially if you are really liking the content and you just want to hurry up and skip. People like you are the reason I do this, it shows your appreciation and boosts my drive to create more free content :)

  • @devconnective8640
    @devconnective8640 5 лет назад

    I tried your video using mamp.
    At first I couldn't access the db, but in the case of the mamp I changed the password to 'root' and it worked. I learned a lot.Thanks from Japan.

  • @akrambagwan9148
    @akrambagwan9148 4 года назад

    I was working on a project and was about to give up and this guy just made me not to.
    Thanks bro

  • @mehulgala07
    @mehulgala07 4 года назад +11

    Those who are getting "ER_NOT_SUPPORTED_AUTH_MODE" error in the DB connection, try the newer NPM package "mysql2". It supports advanced authentication that MySQL 8.0 requires.
    Here's the NPM page link: www.npmjs.com/package/mysql2

  • @arijitsarkar229
    @arijitsarkar229 7 лет назад

    don't know why people are using mongodb or postgre sql in tutorial of nodejs with expression.
    this tutorial simply show how to connect with database (mysql). it is very very helpful.
    thanks a lot.

  • @jejohansen1
    @jejohansen1 2 года назад +4

    Very good tutorial. Some updates(2022) would be to use mysql2 instead of mysql, and to add a port (usually 8889) if you are using MAMP. Thank you Brad

  • @JackMillerIndia
    @JackMillerIndia Год назад

    Such a chill, to the point tutorial... absolutely brilliant, lots of love from confused front-end devs

  • @AdegbengaAgoroCrenet
    @AdegbengaAgoroCrenet 7 лет назад +6

    Thanks Brad for consistently delivering awesome tutorials that are precise, packed with tons of meat and no fluff. Great stuff bruv

    • @apurv5847
      @apurv5847 3 года назад

      I need a help. So I made a login page which works fine when input is correct. But in case if the input goes wrong like either the password or username, it throws error and the server crashes. I don't want that. Instead I want that error to be handled someway but I ain't able to find any way. Please help me with this. I'd really appreciate if you can please.

  • @MuhammadUmar-xw3cb
    @MuhammadUmar-xw3cb 6 лет назад

    You are the best web development teacher on RUclips. Thank You Sir

  • @peterpaul2507
    @peterpaul2507 5 лет назад

    Looked everywhere for something simplified...you made it much easier..thumbs up!

  • @RicardoRodriguez-lr3tj
    @RicardoRodriguez-lr3tj 4 года назад

    I'm learning a lot of English and a lot of web development with this video. This was very useful, thanks a lot.

  • @dmitriimanchurak1671
    @dmitriimanchurak1671 5 лет назад +8

    Really straightforward and clear from the beginning! Thank you for doing this video

    • @apurv5847
      @apurv5847 3 года назад

      I need a help. So I made a login page which works fine when input is correct. But in case if the input goes wrong like either the password or username, it throws error and the server crashes. I don't want that. Instead I want that error to be handled someway but I ain't able to find any way. Please help me with this. I'd really appreciate if you can please.

  • @goodluckoriuwa1669
    @goodluckoriuwa1669 11 месяцев назад

    This is really good. You know it oops at number one on the search... You really need to make an update on this... Its been six years now... You know many things must have changed overtime

  • @RaphaelFernandesWing
    @RaphaelFernandesWing 4 года назад +1

    Congratulations, man. I am from Brazil and I love your tutorials.

  • @itgun
    @itgun 2 года назад

    finally have found the best explanation. And get the code too so i dont have to rewrite everything. Thanks

  • @ghorizon1724
    @ghorizon1724 2 года назад

    I have had problems with the update because of the ID of my table data, thanks 4 explaining it clearly 👌

  • @MartinKarari
    @MartinKarari 3 года назад

    Oh what an introduction. To be frank, I was almost giving up but this made my learning seamless and easy. I can now CRUD using node. Thanks

  • @adityajoshi8065
    @adityajoshi8065 3 года назад

    One of the few channels i have subscribed

  • @eduardoluiz5762
    @eduardoluiz5762 2 года назад

    Thanks for helping me with my web programming homework, hugs from Brazil!

  • @shaynerushton214
    @shaynerushton214 4 года назад

    Okay, so after a long day and a half, here's what I did to get this working. Hoping it helps anyone who struggled at it like i did.
    First, it's important to have your MySQL configuration set to legacy for password values as the connection from node kept throwing an error due to protocol mismatch. Once i reconfigured MySQL to the legacy, it finally connected.
    He doesn't cover installing Bash, so do an npm install bash after you install Terminal, then click the plus sign on the terminal to get the bash terminal.
    Once you do these things, following this tutorial is easy and does what it is supposed to do. Thank you

  • @tushardorale5347
    @tushardorale5347 3 года назад

    This is the most helpful and easy-to-understand video. Thanks, brad.

  • @theblitz9
    @theblitz9 4 года назад

    Watched a few videos and this is definitely the best and easiest to understand and follow

  • @ixahmedxi
    @ixahmedxi 7 лет назад +5

    In ES6, when you have one function parameter, you can delete the parentheses which makes the code cleaner in my opinion :)
    db.connect( err => {
    if (err) { throw err }
    });
    will still work.

    • @devilmanscott
      @devilmanscott 7 лет назад +1

      Though one could argue that the parentheses shows clearly that it's a group of arguments, also it you want to use rest operator then you need to add parentheses.
      Sometimes you have to think how does it look to someone who's never seen your code and how easy is it to reason about your program.
      But I also prefer the cleaner look, but just wanted to show a reason why keeping it might be better, at-least if you are working within a team.

    • @lardosian
      @lardosian 6 лет назад

      It does kinda throw me a bit when there is no parenthesis around the argument, no pun intended!

  • @jlambert12013
    @jlambert12013 4 года назад

    Dude, I’m a beginner but I love these videos. Big shoutout to the person for not blasting me out with intro music too’

  • @muhammadmahmud7562
    @muhammadmahmud7562 Год назад

    Great video. all of the code works fine. It's Still relevant in 2023!

  • @stephenjames2951
    @stephenjames2951 7 лет назад +2

    Love the practical nature of your videos.

  • @fatmirshehu
    @fatmirshehu 7 лет назад +10

    Thank you man, you made me believe I can still do it..!

  • @HamzaKhan-qm5bl
    @HamzaKhan-qm5bl 4 года назад

    Nosql is so fun. Sql needs so much structuring beforehand

  • @smartliga8623
    @smartliga8623 6 лет назад +3

    CREATE DATABASE IF NOT EXISTS will be more suitable example if the task is to create db from code

  • @emilymarin2521
    @emilymarin2521 Год назад

    Wow, very informative, thanks! I watched this video to see if it would show me what I need to begin building a project, and it gives me what I need *and more*, so I'll definitely be rewatching.

  • @chrismartinez5711
    @chrismartinez5711 3 года назад

    I am using MAMP (not pro) and I had a hard time tracing the cause the error it was giving me when db.connect( ) runs. The solution I found was to enter the following argument into createConnection( ) :
    port: '/Applications/MAMP/tmp/mysql/mysql.sock',
    Hope this helps somebody!
    Also, Traversy, once beautifully concise video as always!

    • @traupics_
      @traupics_ 3 года назад

      thats a socket not a port

  • @surajoberai
    @surajoberai 3 года назад

    excatly what needed for my DBMS project ✍

  •  7 лет назад +126

    24:30 - line 87 - that's a nice candidate for SQL injection :)

    •  7 лет назад +48

      He is concatenating SQL query with string he receives from user request. So if user in that requests sends malicious SQL query it will get executed. This vulnerability basically allows you (as a hacker) to do anything with target database.

    • @dragonattack46
      @dragonattack46 7 лет назад +41

      Fortunately you may use "Escaping query values": github.com/mysqljs/mysql#escaping-query-values
      So in this case the query may look like this: let sql = 'UPDATE posts SET title = ' + connection.escape(newTitle) + ' WHERE id = ' + connection.escape(req.params.id) +';

    • @pikachu5223
      @pikachu5223 7 лет назад

      thank you

    • @LOOTS243
      @LOOTS243 7 лет назад +5

      Use parameterized query. blogs.msdn.microsoft.com/sqlphp/2008/09/30/how-and-why-to-use-parameterized-queries/

    • @RahmatAlHakam
      @RahmatAlHakam 6 лет назад +4

      maybe better look like this:
      let sql = 'update posts set title='+ db.escape(newTitle) +' where id='+ db.escape(req.params.id) + '';

  • @ianchin5634
    @ianchin5634 6 лет назад

    Every project I can think of you have a video for thank so much for your hard work

  • @salkohajric9641
    @salkohajric9641 4 года назад

    For ones who had problem connecting with db, around 11:30, password could be just empty string instead of 123456

  • @yonggyulee
    @yonggyulee 2 года назад +1

    This video is still very useful!

  • @ssuriset
    @ssuriset 3 года назад

    Thanks, Travisscott Media!

  • @sameerparab8210
    @sameerparab8210 4 года назад +1

    I really liked this. I always refers to this MAN's videos ( Traversy Media) for Node, MySQL , Mongo..etc....

  • @enricoheise30
    @enricoheise30 4 года назад

    Thank youuuu ! couldn't figure how to show the output in my browser from MySQL/Node. Thanks a lot!!!

  • @ankit30343
    @ankit30343 3 года назад

    This is really very helpful I learned it so fast bcoz you taught it so well❤️❤️

  • @KanavinVithai
    @KanavinVithai 6 месяцев назад

    You are really awesome bro ❤
    Always you are my guru
    Laravel and node I have learned from you 😍

  • @mustakoski471
    @mustakoski471 6 лет назад

    To be honest you helped me understand express framework!!! Well done!!!

  • @robertmonplaisir9519
    @robertmonplaisir9519 3 года назад

    You explain these things well. Thank you very much.

  • @reginaldjongwe1073
    @reginaldjongwe1073 2 года назад

    Thank you Brad for this tutorial

  • @ChrisTian-ox5nr
    @ChrisTian-ox5nr 2 года назад

    LEGEND !! GOT ME MY JOB!

  • @dlj7856
    @dlj7856 6 лет назад

    Thank you so much for your video. It was really helpful for me. I was having hard time in a web project. then your video saved my life.

  • @AlanJonesBurga
    @AlanJonesBurga 5 лет назад

    Awesome!! Easy to understand, clear, and the best intro to understanding Node with mysql. thanks alot!!

  • @keenanreed5341
    @keenanreed5341 2 года назад

    Thanks alot. This was exactly what I was looking for!

  • @abhishekrawat8579
    @abhishekrawat8579 3 года назад

    one tip:
    use err.message instead of err in console.error(), which throw specific error

  • @vishalthapa3101
    @vishalthapa3101 2 года назад +1

    Lots of thanks for providing such a good content :)

  • @dudzpedra
    @dudzpedra 2 года назад

    Really great video! I've twisted the code a little bit to send the results of the query to the screen like 'res.send(results)' for a better development experience! Thanks a lot

  • @mancan912
    @mancan912 7 лет назад

    Thanks alot I'm from Iraq I'm follow your courses is the best continues

    • @TraversyMedia
      @TraversyMedia  7 лет назад +1

      Thanks man, that's awesome I'm able to help people all around the globe :)

  • @tyrrelldavis9919
    @tyrrelldavis9919 5 лет назад +1

    This is such an odd way to do it, but I get that you're trying to teach the concept.
    Awesome stuff.
    Thank you Brad :)

  • @danielgabai5395
    @danielgabai5395 6 лет назад +2

    Thank you so much! This was a hugely helpful tutorial. Keep up the great work!

  • @candycraft65
    @candycraft65 6 лет назад

    good content brad really enjoy your crash courses and your series thank alot brad

  • @princechaudhary3382
    @princechaudhary3382 4 года назад

    you are awesome sir your all videos always very helpful thank you

  • @MuqeetMughal
    @MuqeetMughal 4 года назад

    Thank You So Much Man as a Newbie this Video Changed my Life, Lots of Love Bro

  • @bawagrafix
    @bawagrafix 5 лет назад

    very nicely & quickly explained

  • @julianklumpers
    @julianklumpers 7 лет назад +3

    Hey Brad,
    love your work keep up the good stuff!!
    mabby in one of your future projects you can make a video on how to create and publish a react component library, would really like to learn more on that.
    Greets Julian

  • @Takayaki42
    @Takayaki42 3 года назад

    Very clean and quick guide, thank you!

  • @RicardoNunez90
    @RicardoNunez90 5 лет назад +1

    This was extremely helpful. Thanks for the tutorial.

  • @cacianobeast
    @cacianobeast 7 лет назад

    finally this is the one ive been waiting for

  • @AlexanderKwalsh
    @AlexanderKwalsh 6 лет назад

    Great!, i just got into node js and this is a good start for me . Thank you

  • @rainerfloeter7097
    @rainerfloeter7097 5 лет назад

    Express makes this so much easier. I'm doing it without express just node and mysql and its just a pain in the ass.

  • @aycanocal6506
    @aycanocal6506 4 года назад +1

    Nice tutorial! Easy to understand & implement! Thank you!

    • @apurv5847
      @apurv5847 3 года назад

      I need a help. So I made a login page which works fine when input is correct. But in case if the input goes wrong like either the password or username, it throws error and the server crashes. I don't want that. Instead I want that error to be handled someway but I ain't able to find any way. Please help me with this. I'd really appreciate if you can please.

    • @jamshaidaziz837
      @jamshaidaziz837 Год назад

  • @lukepeterson9854
    @lukepeterson9854 7 лет назад

    Brad, thanks so much for this video. It really helped me understand things easier.

  • @alanray124
    @alanray124 4 года назад

    I love your tutorials

  • @akhedy4905
    @akhedy4905 7 лет назад +1

    Thank you Brad this is what i m waiting for

  • @anterrahi.s4058
    @anterrahi.s4058 5 лет назад

    hey, I taking ur course on udemy full stack web development. good to see you here.

  • @eraswin
    @eraswin 11 месяцев назад

    Thank you for being you 🙏🏻🙏🏻🙏🏻

  • @Waalter_Whitee
    @Waalter_Whitee Год назад

    thanks a lot man such a precise tutorial

  • @stephenwilliams7892
    @stephenwilliams7892 5 лет назад +2

    Thanks a lot Brad, exactly what i was looking for. You are Super !

    • @apurv5847
      @apurv5847 3 года назад

      I need a help. So I made a login page which works fine when input is correct. But in case if the input goes wrong like either the password or username, it throws error and the server crashes. I don't want that. Instead I want that error to be handled someway but I ain't able to find any way. Please help me with this. I'd really appreciate if you can please.

  • @Filosopha
    @Filosopha 7 лет назад

    I LOVE your videos man! I'm getting comfortable with web technologies and your channel is really helping. Thanks for the videos! A request if you ever find time... Joomla as a Framework (not CMS)! Thanks again!

  • @delisandor5337
    @delisandor5337 6 лет назад

    This guy is king

  • @tabishshamim9030
    @tabishshamim9030 4 года назад

    Great tutorial,
    Please make a video on authentication using node js and mysql

  • @mephalanb30
    @mephalanb30 3 года назад

    Good tutorial Brad.

  • @Marcos-zx6ey
    @Marcos-zx6ey 5 лет назад

    great tutorial but consider using app.post, app.delete, app.put, etc too

  • @adamromero
    @adamromero 7 лет назад

    thats a legit intro

  • @darkmift
    @darkmift 5 лет назад +1

    Thank you for sharing your code...saved me a bout an hour of fiddling now I can just use it to teach my boss :D

    • @apurv5847
      @apurv5847 3 года назад

      I need a help. So I made a login page which works fine when input is correct. But in case if the input goes wrong like either the password or username, it throws error and the server crashes. I don't want that. Instead I want that error to be handled someway but I ain't able to find any way. Please help me with this. I'd really appreciate if you can please.

    • @hyperxjourney5837
      @hyperxjourney5837 3 года назад

      @@apurv5847 did you find out mate?

    • @apurv5847
      @apurv5847 3 года назад

      @@hyperxjourney5837 Yeah thanks bro. I solved it. The problem was that when the program couldn't find anything in database the value coming back was null. So just used an if else statement and the problem was solved.

  • @jagdishshetty4782
    @jagdishshetty4782 5 лет назад

    Great tutorial !!! Explained really fast !!! Thx !!!

  • @CristianEnriqueSarabiaMedoza
    @CristianEnriqueSarabiaMedoza 4 года назад

    Thank you very much, I understood very quickly....

  • @turokII
    @turokII 7 лет назад

    This was extremely helpful, thank you! Keep up the great work.

  • @farzadsole6021
    @farzadsole6021 7 лет назад +2

    Hi and thank you for your awesome video tutorials, you are one of my most favourite tutors :)
    +1

    • @apurv5847
      @apurv5847 3 года назад

      I need a help. So I made a login page which works fine when input is correct. But in case if the input goes wrong like either the password or username, it throws error and the server crashes. I don't want that. Instead I want that error to be handled someway but I ain't able to find any way. Please help me with this. I'd really appreciate if you can please.

  • @YoungGrizzly
    @YoungGrizzly 4 года назад

    Thanks for this. I have a new task that requires me to extract data from Observium's Billing table and push that to a NodeJS API endpoint.

  • @HeilTec
    @HeilTec 6 лет назад +1

    Remember to always sanitizer input. Never use input directly in the query.

  • @datsovtsvetan
    @datsovtsvetan 4 года назад

    Гоуем си, брат! (You are big one, brother (брат == brother, Brad is similar to Брат and sounds the same in my language - Bulgarian :) ) You are the best, really! Bless you! Have a great and lovely new year!

  • @ufotofu9
    @ufotofu9 5 лет назад +1

    It worked! Thanks!

  • @gaming_boga
    @gaming_boga 5 лет назад +1

    Hi thanks for ur video helped me a lot !! :)

  • @nshutiyvan582
    @nshutiyvan582 6 лет назад

    Thank you brad for another awesome video

  • @justinahurry
    @justinahurry 5 лет назад +1

    THANK YOUUUUUUUUUUUUUUUUUUUUU YOU SAVED MY LIFE