Client does not support authentication protocol MySQL Node JS - IndianTechnoEra
Latest update Android YouTube

Client does not support authentication protocol MySQL Node JS

 



Error: 

Shows error: Client does not support authentication protocol requested by server. Consider creating my SQL client

State: accessing the data of MySQL database using node js and express js while implementing react application


Code:

index.js

import express from 'express'

import mysql from 'mysql'

const app = express()

const db = mysql.createConnection({

    host:"localhost",

    user:"root",

    password:"mysql1234",

    database:"bookshop"

})

app.get("/",(req,res)=>{

    res.json("Hello backend is here")

}) 

app.get("/books", (req, res)=>{

    const q = "SELECT * FROM books"

    db.query(q, (data,err)=>{

        if(err){

            return res.json(err)

        }

        return res.json(data)

    })

})

app.listen(8181,()=>{

    console.log("Backend connected")

})


Solution 1:

paste the following  code in the workbench and replace your password

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_mysql_password';


Solution 2:

install mysql2 in your server app

npm i mysql2




إرسال تعليق

Feel free to ask your query...
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.