MySQL Database connection from node js application

Поделиться
HTML-код
  • Опубликовано: 17 дек 2019
  • 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"
    3. create a file like "database.js"
    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
    ---------------------------
    pool.query(`select * from registration`, function(err, result, fields) {
    if (err) {
    return console.log(err);
    }
    return console.log(result);
    })

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

  • @elkhanhamet2561
    @elkhanhamet2561 3 года назад +9

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

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

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

  • @Sac-chan
    @Sac-chan 4 месяца назад +2

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

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

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

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

    Very useful for beginners, thanks for making bro ❤️

  • @oluwapamilerinsobiyede3846
    @oluwapamilerinsobiyede3846 Месяц назад

    Life saver, Spent weeks already

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

    Very helpful for beginners, Thank you so much

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

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

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

    simple and to the point. thanks bro.

  • @victorivanov6603
    @victorivanov6603 3 месяца назад +2

    Thank you so much, you deserve more subs!

  • @nirajbadaik6796
    @nirajbadaik6796 3 года назад +3

    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???

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

    thank you so much sir Was indeed helpful.

  • @user-cc1wo9px2u
    @user-cc1wo9px2u 11 месяцев назад

    very clear and neat description

  • @asmit_kr
    @asmit_kr 10 месяцев назад

    Thank u so much, it helped me a lot

  • @mr.awexmen815
    @mr.awexmen815 2 года назад

    thank you very much. this help me very much

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

    Thanks from Brazil!

  • @innovative-thoughts
    @innovative-thoughts 4 года назад

    Very helpful. Thank you

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

    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??

  • @stantarasenko188
    @stantarasenko188 9 месяцев назад

    Thanks for good example

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

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

  • @webdevmaruf
    @webdevmaruf 2 месяца назад

    Thank you!

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

    Thanks ..HELPFUL!!!!!!!!!!!!!!!!!!!

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

    can you implement sequelize with this rest? thanks

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

    very helpful thank you

  • @tamvanvarokah2102
    @tamvanvarokah2102 3 года назад +2

    thanks dude its so helpful

  • @YourHeartFeelings
    @YourHeartFeelings 3 месяца назад

    Thank you very much sir

  • @javiermondragon6918
    @javiermondragon6918 Год назад +1

    Great video, solved my problem

    • @vishnug9450
      @vishnug9450 Год назад +1

      can you tell me how to store that in a variable

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

    could you please create an app with NODE + SQL Server? thanks!

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

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

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

    Thanks bro

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

    Thank u sir

  • @augischadiegils.5109
    @augischadiegils.5109 3 года назад

    Nice

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

    What more can I ask for?
    Thanks bro.

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

    how do i print the result

  • @atharvadeshmukh6328
    @atharvadeshmukh6328 9 месяцев назад

    thanks!!

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

    how you will do though index.hrml file

  • @satyambansal728
    @satyambansal728 3 месяца назад +1

    how to give data to data base from the website

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

    Why you did not show hos to install mysql on localhost?

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

    how we display two table or more

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

    Hello, In the same way I run the code but it showing something access denied error, could you please give explanation to this please,
    E:\procedures_practice_server
    ode_modules\mysql\lib\protocol\Parser.js:437
    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 (E:\procedures_practice_server
    ode_modules\mysql\lib\protocol\sequences\Sequence.js:47:14)
    at Handshake.ErrorPacket (E:\procedures_practice_server
    ode_modules\mysql\lib\protocol\sequences\Handshake.js:123:18)
    at Protocol._parsePacket (E:\procedures_practice_server
    ode_modules\mysql\lib\protocol\Protocol.js:291:23)
    at Parser._parsePacket (E:\procedures_practice_server
    ode_modules\mysql\lib\protocol\Parser.js:433:10)
    at Parser.write (E:\procedures_practice_server
    ode_modules\mysql\lib\protocol\Parser.js:43:10)
    at Protocol.write (E:\procedures_practice_server
    ode_modules\mysql\lib\protocol\Protocol.js:38:16)
    at Socket. (E:\procedures_practice_server
    ode_modules\mysql\lib\Connection.js:88:28)
    at Socket. (E:\procedures_practice_server
    ode_modules\mysql\lib\Connection.js:526:10)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    --------------------
    at Protocol._enqueue (E:\procedures_practice_server
    ode_modules\mysql\lib\protocol\Protocol.js:144:48)
    at Protocol.handshake (E:\procedures_practice_server
    ode_modules\mysql\lib\protocol\Protocol.js:51:23)
    at PoolConnection.connect (E:\procedures_practice_server
    ode_modules\mysql\lib\Connection.js:116:18)
    at Pool.getConnection (E:\procedures_practice_server
    ode_modules\mysql\lib\Pool.js:48:16)
    at Object. (E:\procedures_practice_server\index.js:15:6)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
    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
    }

  • @nidhidwivedi1617
    @nidhidwivedi1617 3 года назад +3

    Really helpful. Thanku so much

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

    how do i output this on a browser??

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

    I am not able to open vs code from command prompt

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

    indian guy are smart

  • @ABUTAHER-wg7gz
    @ABUTAHER-wg7gz 7 месяцев назад

    but how to connect cpanel mysql db?

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

    I typed schema name instead of database name and then it retrieved data

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

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

    • @dreamer6911
      @dreamer6911 7 месяцев назад

      MAYBE UR USING "TYPE":"MODULE" IN UR PACKAGE.JSON FILE

  • @rachitmathur2986
    @rachitmathur2986 3 года назад +1

    ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

  • @smartyarshad303
    @smartyarshad303 2 года назад +3

    Hello sir,
    When I creating database connection it shows depreciation warning
    [DEP0095] DeprecationWarning: timers.enroll() is deprecated. Please use setTimeout instead.

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

    How to update
    Delete

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

  • @ruturajkulkarni5928
    @ruturajkulkarni5928 9 месяцев назад +1

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

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

    Client does not support authentication protocol requested by server; consider upgrading MySQL client : Can someone help?

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

      why are we using php if we can get data from mysql

    • @Sac-chan
      @Sac-chan 4 месяца назад

      run VS Code as administrator

  • @theraildynasty_
    @theraildynasty_ 3 года назад +1

    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
    }

  • @thearjunmishra
    @thearjunmishra 10 месяцев назад

    Not working

  • @user-ku8ry6wr6k
    @user-ku8ry6wr6k 8 месяцев назад

    this is fakhar

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

    chorrrrrrrrrrrr

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

    worst

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

    I follow your step, and WHY IT DID NOT WORK?!!!!!!!

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

    at Function.Module._load (node:internal/modules/cjs/loader:813:14) {
    code: 'PROTOCOL_SEQUENCE_TIMEOUT',
    fatal: true,
    timeout: 10000
    } help me nrother

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

    Thank you!