ER_NOT_SUPPORTED_AUTH_MODE - MySQL server

Solution 1:

For MySQL v8.0 use the following:

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

Solution 2:

enter image description here

You need to reconfigure the Quick Action Settings by clicking the "Reconfigure Link" as shown in the screenshot below. From there, select "Legacy password" for v5.1.


The cause of the error:


You installed the latest "MySQL Version", v8.0. The latest version has a different encryption plugin for authenticating users at login. 5.6, and 5.1 revert to the prior encryption algorithms. Please note, 5.6 & 5.1 have several security vulnerabilities reported by oracle.

Solution 3:

The top-rated answers in this Q/A thread are for the most part valid, but they are unorganized, which is to say the least. A solution is here, however, the solution is bits and pieces amongst three other answers. To offer an answer that is a single solution, more helpfull, and is a time saver, I'll make an attempt to write an answer myself in a way that is clear, concise, and orderly. I will cover the whole problem that Ubuntu users experiance, and in addition, I will add information that's helpfull, and not included in any other answer, that will help readers understand the issue that persist for them.


To Start: The Issue is not a SQL Problem, it is an Ubuntu Problem

The issue that persist for you, has to do with the fact (a fact most software developers/I.T. professionals are probably all already aware of) the 'ROOT' user doesn't have a password in Ubuntu, and is accessible by anyone with $ sudo privileges. To offer clarity for anyone experiencing this issue who might be new to some of the semantics that I am throwing out there; Ubuntu users use the sudo -i command to register as the Root-user, whereas, every other Linux distribution in existence uses a User-ID w/ a Password. In truth, I cannot remember ever needing to be a ROOT user for anything other than Database Management, and always only when I am first installing a Database to a server, though my experience is probably far limited in comparison to some IT professionals out there. My point is, typically using sudo for everything does the Job, but in this case it is problematic, so the important thing to note is the following:


PROBLEM:


Ubuntu lacks a 'ROOT PASSWORD' and this is why everyone experiencing the issue that we are discussing runs a Distribution of the Ubuntu OS/SHELL. And unless we rewrite the Ubuntu kernel, and the practically everything else in the operating system, we cannot give Ubuntu SHELL a "root password".


SOLUTION:

We may not be able to give the Ubuntu SHELL a root password, but we can, and we will, give MySQL a 'ROOT PASSWORD'.





TO EXECUTE THE SOLUTION YOU NEED TO HAVE THE FOLLOWING:

  1. Node.js v12+
  2. NPM (Probably need v5+ but don't quote me on that)
  3. MySQL v8.0+ (obviously)
  4. The MySQL Driver (from npm)



CONFIRMATION:

If you don't already have everything on the list you honestly can't say that this is the issue your dealing with.
If you do have everything on the list

and you are running an Ubuntu distro, then you should be getting an error message that probably looks somthing like the one I got when I had to fix this issue.

My error message read:
ERROR: (28000): Access denied for user 'ajc'@'localhost' 
ERROR: ERROR_NOT_SUPPORTED_AUTH_MODE: Client does not support
authentication protocol requested by server; consider upgrading 
MySQL client

'Client does not support authentication protocol requested by server; consider upgrading MySQL client

If your still reading then your likely in the right place.
  1. To start fixing the problem create an empty Node.js project, and install the MySQL driver as a dependency to it using NPM (you should know how to do this, as you had to do that to have this issue). Add a JavaScript .js file. Call the file, sqltest.js or whatever something like that.

  2. Add the code below to the file you just created.

let mysql = require('mysql');

let connection = mysql.createConnection({
    host     : 'localhost',
    user     : 'root',
    password : '********',
    database : 'DB_App_00',
});

connection.connect(function(err) {
    if (err) {
      return console.error('error: ' + err.message);
    }
  
    console.log('Connected to the MySQL server.');
  });

  1. In the method called 'createConnection' is a JSON OBJ parameter holding the credential values to make a valid connection to the MySQL database server. The user has to equal to 'root', and the database has to exist. Also for a later test add a testing table to the database, with some BS data."

  2. Now open a terminal window, and do your typical updates & upgrades, this is important, which is why every tutorial asks you to do them.

~$: sudo apt update
~$: sudo apt upgrade


  1. After you do your upgrades enter the following command into your terminal:
~$: sudo mysql -u root

  1. It should prompt you for your Ubuntu Password, type it and [ENTER].

The next step is critically important:
  1. Now here is the step that could be considered the medicine and/or the cure to the problem. Your terminal should be open, and you should be inside of the MYSQL Server, under the user 'root'. The terminal should have the cursor flashing at a blank mysql command-line. Within the CMDL copy & paste this:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'ChoosePassword';

mysql> FLUSH PRIVILEGES;

  1. The next part is obvious, change 'ChoosePassword' to a password you will remember while leaving the password within single quotation marks. Change absolutely nothing else, press [ENTER]

  2. If you followed the steps correctly, you now have a MySQL 'ROOT USER' with its own password now. Test it by copy and paste the following at the Ubuntu CMDL:

 ~$: mysql -u root -p 
  • It will prompt you for your new password, type it and [ENTER]

...you should be in, now exit.

mysql>exit
  1. Back to your 'testsql.js' file, alter the credentials to root for the user, password to your password, a valid database, and host to localhost, unless you have a unique need for a different hostname.

let connection = mysql.createConnection({
    host     : 'localhost',
    user     : 'root',
    password : '********',
    database : 'DB_App_00',
});


  1. now use node to run the node test file
~$: node testsql.js

Final Thought:

If it doesn't say connected you did something wrong, but if all went well, you should connect. It took some effort before I got it to work, but this answer should save you some time from reading all the other half written answers.