0

I'm making a program in react native The server has several routes like "clientes.js", "users.js"...

In the app.js of the server I have the function for debugging

app.use((req, res, next)=> {
    const erro = new Error('Not Found');
    erro.status = 404;
    next(erro);
});

This is my mysql.js file

var mysql = require('mysql');
var pool = mysql.createPool({
    user: process.env.MYSQL_USER,
    password:process.env.MYSQL_PASSWORD,
    database:process.env.MYSQL_DATABASE,
    host:process.env.MYSQL_HOST,
    port:process.env.MYSQL_PORT
})
exports.pool = pool;

This is my nodemon.json file

{
    "env" :{
        "MYSQL_USER" : "admin",
        "MYSQL_PASSWORD" : "***",
        "MYSQL_DATABASE" : "database",
        "MYSQL_HOST" : "127.0.0.1",
        "MYSQL_PORT" : 3306
    }
}

Finally the server.js file

const http= require('http');
const app = require('./app');
const port = process.env.PORT || 3000;
const server = http.createServer(app);
app.listen(port,(req,res)=>{
    console.log('Server on');
});

When I use postman to "get localhost:3000" It returns the error

{
    "erro": {
        "mensagem": "Not Found"
    }
}

When I use postman to "get localhost:3000/users/" It returns the error

{
    "error": {
        "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
    },
    "try": "1",
    "message": "ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client"
}

Furthermore, my program does not connect to the server, here is the config.js file

export default {
    apiBaseURL: 'localhost:3000'
}

Usage example in code, part of file login/index.js

const login = () => {
    api.get("http://"+Config.apiBaseURL+"/users/",{
        "user" : user,
        "password" : password
    })
    .then((response) => 
        handleSign(user)
    )
    .catch((err) => {
        setLoginError(true)
    });
}

I'm using version 8.0.32 of workbench, on the server mysql is version 2.18.1, of npm

node_modules/mysql": { "version": "2.18.1", ... }

I've tried begguing some code lines

  • Welcome to stackoverflow! This question might be related https://stackoverflow.com/questions/50093144/mysql-8-0-client-does-not-support-authentication-protocol-requested-by-server It seems your server has an authentication method set that doesn't match the method you're trying from the express server. – Abhishek Ghosh Mar 17 '23 at 09:17

0 Answers0