Nodejs Mysql version problem

Hello again,

The Nodejs site is now online but I have a Mysql problem.
Here is the error message.

{status: “500”,…}

message

:

“Knex: run\n$ npm install mysql --save\nCannot find module ‘mysql’\nRequire stack:\n- /home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/dialects/mysql/index.js\n- /home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/dialects/index.js\n- /home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/knex-builder/internal/config-resolver.js\n- /home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/knex-builder/Knex.js\n- /home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/index.js\n- /home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/knex.js\n- /home/myfolder/domains/my-domain/public_html/app/lib/core/db.js\n- /home/myfolder/domains/my-domain/public_html/app/lib/core/app.js\n- /home/myfolder/domains/my-domain/public_html/app/lib/core/middleware.js\n- /home/myfolder/domains/my-domain/public_html/app/lib/setup/routes.js\n- /home/myfolder/domains/my-domain/public_html/app/lib/server.js\n- /home/myfolder/domains/my-domain/public_html/app/index.js\n- /usr/local/lsws/fcgi-bin/lsnode.js”

stack

:

“Error: Knex: run\n$ npm install mysql --save\nCannot find module ‘mysql’\nRequire stack:\n- /home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/dialects/mysql/index.js\n- /home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/dialects/index.js\n- /home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/knex-builder/internal/config-resolver.js\n- /home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/knex-builder/Knex.js\n- /home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/index.js\n- /home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/knex.js\n- /home/myfolder/domains/my-domain/public_html/app/lib/core/db.js\n- /home/myfolder/domains/my-domain/public_html/app/lib/core/app.js\n- /home/myfolder/domains/my-domain/public_html/app/lib/core/middleware.js\n- /home/myfolder/domains/my-domain/public_html/app/lib/setup/routes.js\n- /home/myfolder/domains/my-domain/public_html/app/lib/server.js\n- /home/myfolder/domains/my-domain/public_html/app/index.js\n- /usr/local/lsws/fcgi-bin/lsnode.js\n at Client_MySQL.initializeDriver (/home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/client.js:202:13)\n at new Client (/home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/client.js:83:12)\n at new Client_MySQL (/home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/dialects/mysql/index.js:21:1)\n at knex (/home/myfolder/nodevenv/domains/my-domain/public_html/app/18/lib/node_modules/knex/lib/knex-builder/Knex.js:16:28)\n at App.setDbConnection (/home/myfolder/domains/my-domain/public_html/app/lib/core/app.js:406:27)\n at App.getDbConnection (/home/myfolder/domains/my-domain/public_html/app/lib/core/app.js:425:25)\n at App.select (/home/myfolder/domains/my-domain/public_html/app/lib/modules/dbconnector.js:15:25)\n at App._exec (/home/myfolder/domains/my-domain/public_html/app/lib/core/app.js:610:57)\n at App.exec (/home/myfolder/domains/my-domain/public_html/app/lib/core/app.js:546:20)\n at App.define (/home/myfolder/domains/my-domain/public_html/app/lib/core/app.js:528:20)”

status

:

“500”

I updated my local server to these versions.
Mysql 8.0.31
MartiaDB 10.10.02

But my online server only runs with MariaDB 10.6. and can only be expanded to a managed server with the update.
Which I don’t want to do because it would cost more.

Is there a way to also work with this version?

Many thanks for your help!

Looks like mysql support is not installed on your server.
Open your server terminal and type

npm install mysql --save

Hi Brian, does that mean that the MySQL server runs under NodeJS/Knex?

I have been using Apache/Nginx for the MySQL server. This gives me food for thought.

I am so expert on that field but it does appear so.
I experienced exactly the same error two days ago on a new site on my vps (centos8 + cPanel) and that was the issue.
After the npm install I got a new error about sharp not being installed so I ran

Npm install sharp --save
in the Wappler terminal and that fixed things.
I assumed the absence of the sharp installer had resulted in a failure to install mysql support onto the server.

1 Like

He worded it incorrectly, he’s referring to the MySQL module/client/driver for NodeJS, not the database server itself

1 Like

That makes a bit more sense. Thank you.

Sorry for any confusion

Brian, no need to apologise, this is a bit more information that needs to be stored in my already saturated brain.

1 Like

Thank you very much,

but unfortunately I now get this error message.

{status: "500", code: "ECONNREFUSED", message: "connect ECONNREFUSED ::1:3306",…}

code

:

"ECONNREFUSED"

message

:

"connect ECONNREFUSED ::1:3306"

stack

:

"Error: connect ECONNREFUSED ::1:3306\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)\n --------------------\n at Protocol._enqueue (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/protocol/Protocol.js:144:48)\n at Protocol.handshake (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/protocol/Protocol.js:51:23)\n at Connection.connect (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/Connection.js:116:18)\n at /home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/knex/lib/dialects/mysql/index.js:66:18\n at new Promise (<anonymous>)\n at Client_MySQL.acquireRawConnection (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/knex/lib/dialects/mysql/index.js:61:12)\n at create (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/knex/lib/client.js:262:39)"

    status

    :

    "500"

Now my locale version no longer works either

{status: "500", code: "ER_NOT_SUPPORTED_AUTH_MODE",…}
code
: 
"ER_NOT_SUPPORTED_AUTH_MODE"
message
: 
"ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client"
stack
: 
"Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client\n    at Handshake.Sequence._packetToError (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\sequences\\Sequence.js:47:14)\n    at Handshake.ErrorPacket (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\sequences\\Handshake.js:123:18)\n    at Protocol._parsePacket (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\Protocol.js:291:23)\n    at Parser._parsePacket (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\Parser.js:433:10)\n    at Parser.write (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\Parser.js:43:10)\n    at Protocol.write (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\Protocol.js:38:16)\n    at Socket.<anonymous> (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\Connection.js:88:28)\n    at Socket.<anonymous> (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\Connection.js:526:10)\n    at Socket.emit (node:events:390:28)\n    at addChunk (node:internal/streams/readable:315:12)\n    --------------------\n    at Protocol._enqueue (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\Protocol.js:144:48)\n    at Protocol.handshake (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\Protocol.js:51:23)\n    at Connection.connect (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\Connection.js:116:18)\n    at C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\dialects\\mysql\\index.js:66:18\n    at new Promise (<anonymous>)\n    at Client_MySQL.acquireRawConnection (C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\dialects\\mysql\\index.js:61:12)\n    at create (C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\client.js:262:39)"
status
: 
"500"

When I created my project as a PHP page, the MySQL connection also worked.
Since I got the idea to create it as a Nodejs page because the routing works automatically and it also has many other advantages, I did that.
But now I can’t get any further :unamused:

Make sure you choose the specific MySQL 8 client in the connection properties of the database connection in server connect and not just regular MySQL / mariadb

I did that for my locale version.
Now I get this error message

But on my online server I can only use MariaDB 10.6. to use

{status: "500",…}
message
: 
"Knex: run\n$ npm install mysql2 --save\nCannot find module 'mysql2'\nRequire stack:\n- C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\dialects\\mysql2\\index.js\n- C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\dialects\\index.js\n- C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\knex-builder\\internal\\config-resolver.js\n- C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\knex-builder\\Knex.js\n- C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\index.js\n- C:\\server\\www\\nodetest\\node_modules\\knex\\knex.js\n- C:\\server\\www\\nodetest\\lib\\core\\db.js\n- C:\\server\\www\\nodetest\\lib\\core\\app.js\n- C:\\server\\www\\nodetest\\lib\\core\\middleware.js\n- C:\\server\\www\\nodetest\\lib\\setup\\routes.js\n- C:\\server\\www\\nodetest\\lib\\server.js\n- C:\\server\\www\\nodetest\\index.js"
stack
: 
"Error: Knex: run\n$ npm install mysql2 --save\nCannot find module 'mysql2'\nRequire stack:\n- C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\dialects\\mysql2\\index.js\n- C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\dialects\\index.js\n- C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\knex-builder\\internal\\config-resolver.js\n- C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\knex-builder\\Knex.js\n- C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\index.js\n- C:\\server\\www\\nodetest\\node_modules\\knex\\knex.js\n- C:\\server\\www\\nodetest\\lib\\core\\db.js\n- C:\\server\\www\\nodetest\\lib\\core\\app.js\n- C:\\server\\www\\nodetest\\lib\\core\\middleware.js\n- C:\\server\\www\\nodetest\\lib\\setup\\routes.js\n- C:\\server\\www\\nodetest\\lib\\server.js\n- C:\\server\\www\\nodetest\\index.js\n    at Client_MySQL2.initializeDriver (C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\dialects\\mysql2\\index.js:33:13)\n    at new Client (C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\client.js:83:12)\n    at new Client_MySQL (C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\dialects\\mysql\\index.js:21:1)\n    at new Client_MySQL2 (C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\dialects\\mysql2\\index.js:9:1)\n    at knex (C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\knex-builder\\Knex.js:16:28)\n    at App.setDbConnection (C:\\server\\www\\nodetest\\lib\\core\\app.js:406:27)\n    at App.getDbConnection (C:\\server\\www\\nodetest\\lib\\core\\app.js:425:25)\n    at App.select (C:\\server\\www\\nodetest\\lib\\modules\\dbconnector.js:15:25)\n    at App._exec (C:\\server\\www\\nodetest\\lib\\core\\app.js:610:57)\n    at App.exec (C:\\server\\www\\nodetest\\lib\\core\\app.js:546:20)"
status
: 
"500"

database connections in server connect can be different per target. Did you choose MySQL 8 for local but the regular mysql for remote? You can have different settings by switching the active target

yes, I did that.
But now I get error messages online and locally

You should do that in the Server Connect > Globals, not in the Database Manager.

I did exactly that

My local Version works now but the online Version still not

How can i fix this?

{status: "500", code: "ECONNREFUSED", message: "connect ECONNREFUSED ::1:3306",…}

code

:

"ECONNREFUSED"

message

:

"connect ECONNREFUSED ::1:3306"

stack

:

"Error: connect ECONNREFUSED ::1:3306\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)\n --------------------\n at Protocol._enqueue (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/protocol/Protocol.js:144:48)\n at Protocol.handshake (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/protocol/Protocol.js:51:23)\n at Connection.connect (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/Connection.js:116:18)\n at /home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/knex/lib/dialects/mysql/index.js:66:18\n at new Promise (<anonymous>)\n at Client_MySQL.acquireRawConnection (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/knex/lib/dialects/mysql/index.js:61:12)\n at create (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/knex/lib/client.js:262:39)"

    status

    :

    "500"

many thanks for your help

I’m now trying to specify the direct IP “as mentioned here”.

Now I get this error message:
{status: “500”, code: “ER_ACCESS_DENIED_ERROR”,…}
code
:
“ER_ACCESS_DENIED_ERROR”
message
:
“ER_ACCESS_DENIED_ERROR: Access denied for user ‘myfolder_relaunch’@‘myHost’ (using password: YES)”
stack
:
“Error: ER_ACCESS_DENIED_ERROR: Access denied for user ‘myfolder_relaunch’@‘myHost’ (using password: YES)\n at Sequence._packetToError (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)\n at Handshake.ErrorPacket (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)\n at Protocol._parsePacket (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/protocol/Protocol.js:291:23)\n at Parser._parsePacket (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/protocol/Parser.js:433:10)\n at Parser.write (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/protocol/Parser.js:43:10)\n at Protocol.write (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/protocol/Protocol.js:38:16)\n at Socket. (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/Connection.js:88:28)\n at Socket. (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/Connection.js:526:10)\n at Socket.emit (node:events:513:28)\n at addChunk (node:internal/streams/readable:324:12)\n --------------------\n at Protocol._enqueue (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/protocol/Protocol.js:144:48)\n at Protocol.handshake (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/protocol/Protocol.js:51:23)\n at Connection.connect (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/mysql/lib/Connection.js:116:18)\n at /home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/knex/lib/dialects/mysql/index.js:66:18\n at new Promise ()\n at Client_MySQL.acquireRawConnection (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/knex/lib/dialects/mysql/index.js:61:12)\n at create (/home/myfolder/nodevenv/domains/mydomain.de/public_html/app/18/lib/node_modules/knex/lib/client.js:262:39)”
status
:
“500”

Check the Port Number for the remote database under DB Connection options. In my case, MySQL remote databases are accessible on the Port Number 9910.