javascriptmysqlnode.jslinuxconfiguration

ER_NOT_SUPPORTED_AUTH_MODE - MySQL server



Failed at Connecting Node.js Server to MySQL-Database


        I had MariaDB" installed on a "Node.js Server", but decided that I wanted to use a SQL Database instead. I uninstalled, and completely removed "MariaDB", after which, I proceeded to install the "Community Ed." "MySQL Database". After going through the entire *'MySQL Setup Process'**, I made several attempts to connect to the database via a JavaScript document that implemented the de facto code snippet for a JS DB Connection — my DB-connection document is posted as a code snippet bellow — shown in the code snippet bellow. Disappointingly, the JS/SQL connection failed at each attempt.



Here is the Failed Connection Error Message that I received:



"ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication
protocol requested by server. Consider upgrading MariaDB client."



JS/SQL Connection Snippet that I am using:



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


Solution

  • I figure that some MySQL versions have the authentication for the establishment of a connection a bit messed up. All I had to do was add the line "insecureAuth" : true to the CreateConnection(...) credentials.

    var connection = mysql.createConnection({
      host     : 'localhost',
      user     : 'root',
      password : '********',
      database : 'vod_bill_database',
      insecureAuth : true
    }); 
    

    The error is gone now, and the client is successfully connecting.