Problem in mysql used in nodejs
const mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '123456789',
database : 'userdata'
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err);
return;
}
console.log('connected as id ' + connection.threadId);
});
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
Step 2: Navigate to Software > MySQL Upgrade or type “MySQL” into the search bar. You may also find it under SQL Services > MySQL/MariaDB Upgrade. Step 3: Select the version of MySQL you want to upgrade to and click Next. Now follow the upgrade steps, and it'll take care of everything for you.
Windows users can employ PowerShell or the command prompt and Linux and MacOS have the Terminal. To check the version your MySQL is running, type and execute mysql -V (note the uppercase V) in the command line. As you can see, the MySQL version for this system is 10.4.
Had the same problem.
Install MySQL Workbench
Execute this query: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456789';
in MySQL Workbench
Head back over to Node.js and try running the file again. It should work, at least it did for me.
In any database software (mysql workbench,datagrip, dbeaver...):
First run this query:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Second, if your problem still persists, run this query:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
Combining and running these two queries separately worked for me with dockorize mysql.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With