MySQL Node - change Host Variable

Hello, i'm using the MySql node with the ui node for inputs and results display.

I have a dropdown list filled with all the possible database to connect.

How can i send the selected database from the dropdown list to the "Host" property of the Mysql node ?
Inside the msg.topic with the sql request ?

  1. What have you tried so far?
  2. What do you see if you connect a debug node (displaying the complete msg object) to the ui node you are using?
  3. Exactly which ui node are you using?
  4. How are you building the sql statement now?
  5. Have you tried using a template node (not the ui-template) to build the sql statement?

You should be able to create a small flow where the ui node is connected to a template node which is connected to a debug, What results you get building the sql statement?

Assuming you are using node-red-node-mysql then the terminology in the node config is not particularly good. It refers to a mysql database to connect to when actually it is referring to a mysql server. Each server can itself manage multiple databases.
The database you want to use is specified in the SQL statement but the server you want must (as far as I know) be preselected in the node and cannot be changed at run time.
There may be other mysql nodes that allow the server to be selected at runtime, I don't know.

@colin is correct - that node does not allow dynamic connections to different servers.

Actually I am in part wrong. The config node does specify both the server and the database, but you still can't change it at runtime.

1 Like

Thanks for your answer.

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