• Register
0 votes
142 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 37 views
0 votes
1 answer 1.4K views
1.4K 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 1.6K views
1.6K 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
1 vote
2 answers 672 views
672 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 19 views
19 views
Problem: I am very new to cordova, phonegap, ant,sdk,jdk. I am learning to use phonegap/cordova. Everything is installed properly on my machine i.e cordova, phonegap, ant,sdk,jdk. But now suddenly it started saying that: "’Node' is not recognized as an ... insufficient knowledge I am unable to fix this issue. I am looking for cordova and phonegap experts who can help me in fixing this issue.
asked Sep 2, 2020 Raphael Pacheco 4.9k points
0 votes
2 answers 414 views
414 views
Problem : I am new to Programming. I have created a Maven Project, the JavaScript project is cloned as the git sub-module inside Maven Project. My directory structure is as below mavenapp/src/main/javascript/[npm project files] and inside the package.json my test is looking as below : " ... install But it is not working for me.. npm version : 5.5.1 node version : 9.3.0 How can I fix above error?
asked Mar 3, 2020 mphil 2.3k points
0 votes
1 answer 353 views
353 views
Problem : Currently I am learning Homebrew (Mojave). Recently I tried to install the node using Homebrew (Mojave) but after sometime my Php stopped working and now if I try to run the command php -v I face below error: php -v dyld: Library not loaded: /usr/local ... from: /usr/local/bin/php Reason: image not found I have also tried to uninstall my both node and icu4c but my problem still persists
asked Feb 20, 2020 mphil 2.3k points
0 votes
1 answer 1.3K views
1.3K views
Problem : I am new to type script and unable to compile my type script file. When I try to hit Ctrl+Shift+B in my VS Code, I face below error " ‘Tsc' is not recognized as an internal or external command, operable program or batch file." I used ... C:\Users\mphil\AppData\Roaming\npm\node_modules\typescript\bin\tsc C:\Users\mphil\AppData\Roaming\npm `-- typescript@2.1.5 How to fix above error?
asked Feb 15, 2020 mphil 2.3k points
0 votes
1 answer 1.6K views
1.6K views
Problem : I am beginner in the node.js .Currently I am trying to install node.js using the below command npm install nodemon --save. But when I try to run a server with below command nodemon server.js. then in my terminal I face below error: “Nodemon is not recognized as internal or external command, operable program or batch file”
asked Feb 13, 2020 mphil 2.3k points
0 votes
2 answers 509 views
509 views
Problem : I want to to run my NodeJS version with the nvm but getting following error: $ nvm use v4.2.4 nvm is not compatible with the npm config "prefix" option: currently set to "/Users/z/.npm-global"Run `npm config delete prefix` or `nvm use --delete- ... it. I have set the prefix on purpose to avoid the sudo npm How can I use nvm without losing the prefix for my globally installed packages?
asked Nov 29, 2019 alecxe 7.5k points