# ER\_NOT\_SUPPORTED\_AUTH\_MODE: How to replace use\_your\_user?

**URL:** <https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489>\
**Category:** General\
**Created:** [2 March 2020 10:15 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489 "2020-03-02T10:15:20Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![finnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/finnic/32/17739_2.png) [@finnic](https://discourse.nodered.org/u/finnic)\
**Post date:** [2 March 2020 10:15 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/1 "2020-03-02T10:15:20Z")

</div>

Hi, I know this has been discussed elsewhere, but for the life of me, I can't seem to figure this out. All is fine on mysql 5. , but I need to use digitalocean, so I can only use mysql 8.

Getting this error:

```auto
"Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client"

```

DO's suggestion is the following:

```auto
As a workaround, you can connect using MySQL 8.x and issue the following statement, which will change the password type the server will accept for the current user. Replace use_your_user with your MySQL username, and replace use_your_password with the user’s current password. After successfully executing the statement, you should be able to connect to MySQL with a 5.x client or an application that does not support caching_sha2_password

```

Questions:

1. Where in nodered do I replace use\_your\_user with my MySQL username?
2. Where in nodered do I replace use\_your\_password with the user's current password?

I assume it should be done in some "raw code" view, but I can't find any. Any ideas would be greatly appreciated.

Edit: I'm using the `node-red-node-mysql` node

---

<div class="post-metadata">

**Author:** ![unixneo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/unixneo/32/17441_2.png) [@unixneo](https://discourse.nodered.org/u/unixneo)\
**Post date:** [2 March 2020 10:17 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/2 "2020-03-02T10:17:47Z")

</div>

Sorry, a question in reply: You are using the `node-red-node-mysql` node?

---

<div class="post-metadata">

**Author:** ![finnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/finnic/32/17739_2.png) [@finnic](https://discourse.nodered.org/u/finnic)\
**Post date:** [2 March 2020 10:18 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/3 "2020-03-02T10:18:47Z")

</div>

Thanks, yes, that is what I'm using: node-red-node-mysql

---

<div class="post-metadata">

**Author:** ![unixneo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/unixneo/32/17441_2.png) [@unixneo](https://discourse.nodered.org/u/unixneo)\
**Post date:** [2 March 2020 10:21 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/4 "2020-03-02T10:21:45Z")

</div>

Have you considered just importing `mysql` into `node` directly using `npm` and writing a Node-RED function to do your `mysql` queries?

That is what I do (to get past issues with `node-red-node-mysql`) and it works very well (flawlessly in fact).

---

<div class="post-metadata">

**Author:** ![finnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/finnic/32/17739_2.png) [@finnic](https://discourse.nodered.org/u/finnic)\
**Post date:** [2 March 2020 10:24 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/5 "2020-03-02T10:24:13Z")

</div>

thanks,

1. I did import the node using npm
2. Not sure how to go about writing that function in nodered. Would you have any pointers / templates to share? I'm on an extremely basic level in my coding knowledge, but very eager to learn. Thanks again

---

<div class="post-metadata">

**Author:** ![unixneo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/unixneo/32/17441_2.png) [@unixneo](https://discourse.nodered.org/u/unixneo)\
**Post date:** [2 March 2020 10:27 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/6 "2020-03-02T10:27:48Z")

</div>

Here is an example (but the app is different, you will need to modify, of course):

```auto
var mysql = global.get("mysql");
var moment = global.get("moment");
var connection = mysql.createConnection({
  host: "localhost",
  user: "my_cool_user_name",
  port: "/var/run/mysqld/mysqld.sock",
  password: "my_clever_password",
  database: "my_awesome_database"
});
var newMsg = {};
var thetopic;
var clientid = "my_client_id";
var unixtime = moment().unix();
if (unixtime < 1) {
  unixtime = 9999;
}
if (msg.topic) {
  thetopic = msg.topic;
} else {
  thetopic = "TBD";
}
var thepayload;
var campaignid;
if (msg.payload) {
  thepayload = msg.payload;
  var a = thetopic.split("/");
  var cid = a[2];
  campaignid = parseInt(cid);
} else {
 thepayload = "TBD";
}

if (campaignid > 0 && parseInt(thepayload) > -1) {
  connection.query(

    "UPDATE ad_server_campaigns set weight = " +
      thepayload +
      " WHERE campaignid = " +
      campaignid,
    function(err, results, fields) {
      console.log(err);
      console.log(results);
      connection.end();
    }
  );
}
return msg;

```

---

<div class="post-metadata">

**Author:** ![finnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/finnic/32/17739_2.png) [@finnic](https://discourse.nodered.org/u/finnic)\
**Post date:** [2 March 2020 10:28 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/7 "2020-03-02T10:28:52Z")

</div>

Thanks! Will try this out

---

<div class="post-metadata">

**Author:** ![unixneo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/unixneo/32/17441_2.png) [@unixneo](https://discourse.nodered.org/u/unixneo)\
**Post date:** [2 March 2020 10:31 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/8 "2020-03-02T10:31:19Z")

</div>

Welcome.

Don't forgot to add any required files you need to `settings.js` , for example from the code above:

```auto
var mysql = global.get("mysql");
var moment = global.get("moment");

```

Have you done that before?

---

<div class="post-metadata">

**Author:** ![finnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/finnic/32/17739_2.png) [@finnic](https://discourse.nodered.org/u/finnic)\
**Post date:** [2 March 2020 10:34 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/9 "2020-03-02T10:34:13Z")

</div>

Haven't done this before. Figuring everything out as I go along. I think I'll need to go through a tutorial on how to write a javascript function to connect to mysql - to not miss any steps here.

PS: Any known drawbacks when using python instead of JS inside nodered?

---

<div class="post-metadata">

**Author:** ![unixneo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/unixneo/32/17441_2.png) [@unixneo](https://discourse.nodered.org/u/unixneo)\
**Post date:** [2 March 2020 10:36 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/10 "2020-03-02T10:36:18Z")

</div>

Here ya go... an example in `settings.js`

```auto
   functionGlobalContext: {
        mysql:require('mysql'),
        moment:require('moment')
    },

```

Of course, you will need to `npm` these libs into `node` if you have not already.

Also, many will advise you, you do not need `moment`, but for some reason, it works better for me this way. You can just omit it (`moment`) if you want.

No comment on `Python` in Node-RED. I'm a big Python fan but only write JS in Node-RED (since it is based on `node.js`).

Cheers and Good Luck.

Hope this helped in some small way.

---

<div class="post-metadata">

**Author:** ![finnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/finnic/32/17739_2.png) [@finnic](https://discourse.nodered.org/u/finnic)\
**Post date:** [2 March 2020 10:40 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/11 "2020-03-02T10:40:41Z")

</div>

Thanks a lot! I'm sure it will, trying it out now

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2020 13:44 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/12 "2020-03-02T13:44:38Z")

</div>

> [@finnic](#):
>
> - Where in nodered do I replace use\_your\_user with my MySQL username?
> - Where in nodered do I replace use\_your\_password with the user's current password?

That is the user and password that you enter in the mysql node.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/70a595b846556737618af619d0c52ece231746db.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2020 13:47 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/13 "2020-03-02T13:47:32Z")

</div>

Looking at your question again, when it says 'replace' what it means is that have to run the command that (presumably) is on the next line, using your use and pwd in the command. The command is (I imagine) supposed to be run in the mysql command line client, it is nothing to do with node-red.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 May 2020 13:47 UTC](https://discourse.nodered.org/t/er-not-supported-auth-mode-how-to-replace-use-your-user/22489/14 "2020-05-01T13:47:35Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
