I try to do the Node.js MySQL tutorial. https://www.w3schools.com/nodejs/nodejs_mysql.asp
- I have downloaded MySQL from here: https://dev.mysql.com/downloads/mysql/
- I clicked on the file and installed it.
- Now I have it in my Mac System Preferences > MySQL
- I put that in Terminal: npm install mysql
- In demo_db_connection.js I put
var mysql = require('/Users/myName/node_modules/mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "myPassword"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
});
- Then in Termimal: cd (folder where I have the file)
- node demo_db_connection.js
- It gives me a long error. At the end:
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
I remember the password but I am not sure if I get the user right. I tried: localhost, myName, root. Could that be the cause of the error? How to solve it?
In require I put the address where I have the node modules. I am not sure if that is right?