Node JS and mysql not connecting (client does not support authentication protocol requested by server consider upgrading mysql client)
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 commandline):
npm install mysql
After I installed the mysql npm I made an index.js file and in that file I tried to make the connection with my database.
This is the code inside my index.js file to make a connection with mysql:
//Gebruik mysql npm module voor de mysql database
const mysql = require('mysql');
//Geef connectie details aan
var connection = mysql.createConnection(
host : 'localhost',
user : 'root',
port : '3306',
password : 'tombal10',
database : 'fys'
);
connection.connect((err) =>
//Als er geen error is print dan 'Database is geconnect!'
if(!err)
console.log('Database is geconnect!');
//Als er wel een error is print dan 'Database connectie niet gelukt!'
else
console.log('Database connectie niet gelukt! : '+ JSON.stringify(err, undefined,2));
);
Then I tried to run the code and see if the connection with mysql worked. I typed this in the command line:
node index.js
This is the error message I got in the command prompt :
error image
Does anyone know how I can fix this error and get a connection with my mysqldatabase in nodejs ?
Any kind of help is appreciated
mysql node.js database npm database-connection
add a comment |
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 commandline):
npm install mysql
After I installed the mysql npm I made an index.js file and in that file I tried to make the connection with my database.
This is the code inside my index.js file to make a connection with mysql:
//Gebruik mysql npm module voor de mysql database
const mysql = require('mysql');
//Geef connectie details aan
var connection = mysql.createConnection(
host : 'localhost',
user : 'root',
port : '3306',
password : 'tombal10',
database : 'fys'
);
connection.connect((err) =>
//Als er geen error is print dan 'Database is geconnect!'
if(!err)
console.log('Database is geconnect!');
//Als er wel een error is print dan 'Database connectie niet gelukt!'
else
console.log('Database connectie niet gelukt! : '+ JSON.stringify(err, undefined,2));
);
Then I tried to run the code and see if the connection with mysql worked. I typed this in the command line:
node index.js
This is the error message I got in the command prompt :
error image
Does anyone know how I can fix this error and get a connection with my mysqldatabase in nodejs ?
Any kind of help is appreciated
mysql node.js database npm database-connection
add a comment |
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 commandline):
npm install mysql
After I installed the mysql npm I made an index.js file and in that file I tried to make the connection with my database.
This is the code inside my index.js file to make a connection with mysql:
//Gebruik mysql npm module voor de mysql database
const mysql = require('mysql');
//Geef connectie details aan
var connection = mysql.createConnection(
host : 'localhost',
user : 'root',
port : '3306',
password : 'tombal10',
database : 'fys'
);
connection.connect((err) =>
//Als er geen error is print dan 'Database is geconnect!'
if(!err)
console.log('Database is geconnect!');
//Als er wel een error is print dan 'Database connectie niet gelukt!'
else
console.log('Database connectie niet gelukt! : '+ JSON.stringify(err, undefined,2));
);
Then I tried to run the code and see if the connection with mysql worked. I typed this in the command line:
node index.js
This is the error message I got in the command prompt :
error image
Does anyone know how I can fix this error and get a connection with my mysqldatabase in nodejs ?
Any kind of help is appreciated
mysql node.js database npm database-connection
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 commandline):
npm install mysql
After I installed the mysql npm I made an index.js file and in that file I tried to make the connection with my database.
This is the code inside my index.js file to make a connection with mysql:
//Gebruik mysql npm module voor de mysql database
const mysql = require('mysql');
//Geef connectie details aan
var connection = mysql.createConnection(
host : 'localhost',
user : 'root',
port : '3306',
password : 'tombal10',
database : 'fys'
);
connection.connect((err) =>
//Als er geen error is print dan 'Database is geconnect!'
if(!err)
console.log('Database is geconnect!');
//Als er wel een error is print dan 'Database connectie niet gelukt!'
else
console.log('Database connectie niet gelukt! : '+ JSON.stringify(err, undefined,2));
);
Then I tried to run the code and see if the connection with mysql worked. I typed this in the command line:
node index.js
This is the error message I got in the command prompt :
error image
Does anyone know how I can fix this error and get a connection with my mysqldatabase in nodejs ?
Any kind of help is appreciated
mysql node.js database npm database-connection
mysql node.js database npm database-connection
edited Nov 13 '18 at 14:35
johnny
asked Nov 13 '18 at 14:18
johnnyjohnny
155
155
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
instead of
mysqlConnection.connect((err) => {
use
connection.connect((err) =>
//Als er geen error is print dan 'Database is geconnect!'
if(!err)
console.log('Database is geconnect!');
//Als er wel een error is print dan 'Database connectie niet gelukt!'
else
console.log('Database connectie niet gelukt! : '+ 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
It now gives me another error: client does not support authentication protocol requested by server consider upgrading mysql client
– johnny
Nov 13 '18 at 14:32
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
– Sayed Mohd Ali
Nov 13 '18 at 14:34
Thanks my brother it works now!
– johnny
Nov 13 '18 at 14:42
Your most welcome :)
– Sayed Mohd Ali
Nov 14 '18 at 6:10
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283060%2fnode-js-and-mysql-not-connecting-client-does-not-support-authentication-protoco%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
instead of
mysqlConnection.connect((err) => {
use
connection.connect((err) =>
//Als er geen error is print dan 'Database is geconnect!'
if(!err)
console.log('Database is geconnect!');
//Als er wel een error is print dan 'Database connectie niet gelukt!'
else
console.log('Database connectie niet gelukt! : '+ 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
It now gives me another error: client does not support authentication protocol requested by server consider upgrading mysql client
– johnny
Nov 13 '18 at 14:32
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
– Sayed Mohd Ali
Nov 13 '18 at 14:34
Thanks my brother it works now!
– johnny
Nov 13 '18 at 14:42
Your most welcome :)
– Sayed Mohd Ali
Nov 14 '18 at 6:10
add a comment |
instead of
mysqlConnection.connect((err) => {
use
connection.connect((err) =>
//Als er geen error is print dan 'Database is geconnect!'
if(!err)
console.log('Database is geconnect!');
//Als er wel een error is print dan 'Database connectie niet gelukt!'
else
console.log('Database connectie niet gelukt! : '+ 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
It now gives me another error: client does not support authentication protocol requested by server consider upgrading mysql client
– johnny
Nov 13 '18 at 14:32
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
– Sayed Mohd Ali
Nov 13 '18 at 14:34
Thanks my brother it works now!
– johnny
Nov 13 '18 at 14:42
Your most welcome :)
– Sayed Mohd Ali
Nov 14 '18 at 6:10
add a comment |
instead of
mysqlConnection.connect((err) => {
use
connection.connect((err) =>
//Als er geen error is print dan 'Database is geconnect!'
if(!err)
console.log('Database is geconnect!');
//Als er wel een error is print dan 'Database connectie niet gelukt!'
else
console.log('Database connectie niet gelukt! : '+ 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
instead of
mysqlConnection.connect((err) => {
use
connection.connect((err) =>
//Als er geen error is print dan 'Database is geconnect!'
if(!err)
console.log('Database is geconnect!');
//Als er wel een error is print dan 'Database connectie niet gelukt!'
else
console.log('Database connectie niet gelukt! : '+ 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
edited Nov 13 '18 at 14:36
answered Nov 13 '18 at 14:27
Sayed Mohd AliSayed Mohd Ali
1,0971319
1,0971319
It now gives me another error: client does not support authentication protocol requested by server consider upgrading mysql client
– johnny
Nov 13 '18 at 14:32
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
– Sayed Mohd Ali
Nov 13 '18 at 14:34
Thanks my brother it works now!
– johnny
Nov 13 '18 at 14:42
Your most welcome :)
– Sayed Mohd Ali
Nov 14 '18 at 6:10
add a comment |
It now gives me another error: client does not support authentication protocol requested by server consider upgrading mysql client
– johnny
Nov 13 '18 at 14:32
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
– Sayed Mohd Ali
Nov 13 '18 at 14:34
Thanks my brother it works now!
– johnny
Nov 13 '18 at 14:42
Your most welcome :)
– Sayed Mohd Ali
Nov 14 '18 at 6:10
It now gives me another error: client does not support authentication protocol requested by server consider upgrading mysql client
– johnny
Nov 13 '18 at 14:32
It now gives me another error: client does not support authentication protocol requested by server consider upgrading mysql client
– johnny
Nov 13 '18 at 14:32
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
– Sayed Mohd Ali
Nov 13 '18 at 14:34
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
– Sayed Mohd Ali
Nov 13 '18 at 14:34
Thanks my brother it works now!
– johnny
Nov 13 '18 at 14:42
Thanks my brother it works now!
– johnny
Nov 13 '18 at 14:42
Your most welcome :)
– Sayed Mohd Ali
Nov 14 '18 at 6:10
Your most welcome :)
– Sayed Mohd Ali
Nov 14 '18 at 6:10
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283060%2fnode-js-and-mysql-not-connecting-client-does-not-support-authentication-protoco%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown