• Register
0 votes
215 views

Problem :

I am very new to node.js and MySQL and I have just started setting up and also trying out some basic code. But, I am unable to make even the simple connection to a server for some reason. I have also installed a newest MySQL Community 8.0 database along with the Node.JS with the default settings.

Below is my node.js code

    Var sql = require('sql');

    var mycon = sql.createConnection({
      host: "localhost",
      user: "root",
      password: "password",
      insecureAuth : true
    });

   mycon.connect(function(err) {
      if (err) throw err;
      console.log("Connected!");
    });

 

My Error:

Client does not support authentication protocol requested by server consider upgrading mysql client”

 

7 5 2
3,870 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

You need to execute the below query in MYSQL Workbench

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

Where the root is your user localhost is your URL and password is your password

Then run below query to refresh the privileges:

flush privileges;

After that you can try connecting using the node after you do so.

If that does not work then try it without @'localhost' part.

OR

In your Mysql Latest docker container try to run below query

ALTER USER root IDENTIFIED WITH mysql_native_password BY 'password';

 Hope the above listed solutions will fix your issue.

9 7 4
38,600 points

Related questions

0 votes
1 answer 5 views
5 views
Problem: I can't make a simple connection to the server for some reason. I install the newest MySQL Community 8.0 database along with Node.JS with default settings. This is my node.js code var mysql = require('mysql'); var con = mysql.createConnection({ host: " ... html https://github.com/mysqljs/mysql/issues/1507 But I am still not sure how to fix my problem. Any help would be appreciated :D
asked 3 days ago anika11 32k points
0 votes
1 answer 8 views
8 views
Problem: How can I fix this problem?
asked 2 days ago salim1 60.6k points
0 votes
1 answer 6 views
6 views
Problem: I'm using the node-request module, regularly sending GET requests to a set of URLs and, sometimes, getting the error below on some sites. Error: 29472:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:683 Any help is appreciated.
asked Mar 23 ummesalma 29.2k points
0 votes
1 answer 14 views
14 views
Problem: How to deal with this one : Er_access_denied_error: access denied for user 'root'@'localhost' (using password: no)
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 1.8K views
1.8K views
Problem : I am new to NodeJS and trying to connect to mySQL through the NodeJS file, however I am facing the below error : { Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES) at Handshake.Sequence._packetToError (/home/alecxe/Node ... bar" AS second_field', function(err, results, fields) { console.log(err); console.log(results); myconnection.end(); } );
asked Dec 6, 2019 alecxe 7.5k points
0 votes
1 answer 2 views
2 views
Problem: I've been trying to request an access code from spotify so that I can get an access token and refresh it but for some reason I'm getting an error saying "malformed or illegal request". I think it might have something to do with the redirect_uri. I'm not really sure at all how I'm supposed to format it and if it really matters.How to solve this?
asked 2 days ago sumaiya simi 43.9k points
1 vote
2 answers 969 views
969 views
Problem : I am very new to the Node.js and I am having few issues. I am using the Node.js 4.10 and Express 2.4.3. While trying to execute my code I am receiving below error : Error: Can't render headers after they are sent to the client. ... , scope: 'offline_access,email,user_about_me,user_activities,manage_pages,publish_stream', failedUri: '/noauth' }) ])); realapp.use(realapp.router); }); . . .
asked Dec 12, 2019 alecxe 7.5k points
0 votes
1 answer 137 views
137 views
Problem: Facing this error message: Unchecked runtime.lasterror: could not establish connection. receiving end does not exist.
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
0 answers 7 views
7 views
Problem: user "root" does not have permission to access the dev dir
asked Feb 19 Dan phillip 4.8k points
0 votes
1 answer 2.1K views
2.1K views
Problem : I had recently uninstalled the Postgres10 and after that reinstalled the Postgres10. After that I went to run a Node, Express, React application that relies on connecting to a Postgres10 database and also communicates with it using Sequelize. Initially I was unable to ... app at in the browser. Does anyone have any idea what is going wrong? Please suggest me the solution for my error.
asked Nov 22, 2019 peterlaw 6.9k points