Node JS and mysql not connecting (client does not support authentication protocol requested by server consider upgrading mysql client)

后端 未结 4 1326
再見小時候
再見小時候 2021-01-19 08:09

I\'m trying to connect my NodeJs application with a mysql database but its not connecting for some reason.

I did install the mysql npm like this (typed this in comma

4条回答
  •  抹茶落季
    2021-01-19 08:30

    Instead of

    mysqlConnection.connect((err) => {
    

    use

    connection.connect((err) => {
    
    if(!err)
        console.log('Database is connected!');
    else
        console.log('Database not connected! : '+ JSON.stringify(err, undefined,2));
    });
    

    [Here the is tutorials reference for the code]1

    For your mysql error:

    Execute the following query in MYSQL Workbench:

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'
    

    Try connecting using node after you do so.

提交回复
热议问题