I want to perform CRUD operations from node.js

How to get my MariaDB database details into my node application?
// config/connection.js
module.exports = {
host: ‘your-mariadb-host’, // e.g., ‘localhost’ or an IP address
user: ‘your-mariadb-username’, // e.g., ‘root’
password: ‘your-mariadb-password’, // e.g., ‘password’
database: ‘your-mariadb-database’, // e.g., ‘frappe_database’
port: 3306 // default MariaDB port
};

How can get these details from mariadb ?

most info is included in:
frappe-bench/sites/yoursitename.com/site_config.json. This has user, password and database.

host is the IP address of your server (or DNS name if you have DNS setup on your network)
MariaDB port is the standard 3306 (unless you changed it)

I’m Getthing This Error while running the server
node index.js
Server is running on port 8000
Error connecting to the database: Error: connect ETIMEDOUT
at Connection._handleConnectTimeout (C:\Users\Admin\Desktop\Backend\node_modules\mysql\lib\Connection.js:409:13)
at Object.onceWrapper (node:events:633:28)
at Socket.emit (node:events:519:28)
at Socket._onTimeout (node:net:590:8)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7)
--------------------
at Protocol._enqueue (C:\Users\Admin\Desktop\Backend\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Protocol.handshake (C:\Users\Admin\Desktop\Backend\node_modules\mysql\lib\protocol\Protocol.js:51:23)
at Connection.connect (C:\Users\Admin\Desktop\Backend\node_modules\mysql\lib\Connection.js:116:18)
at Object. (C:\Users\Admin\Desktop\Backend\index.js:87:5)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions…js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
errorno: ‘ETIMEDOUT’,
code: ‘ETIMEDOUT’,
syscall: ‘connect’,
fatal: true

const con = mysql.createConnection({
host: “DNS code”,
user: “DNS code:8000”,
password: “db_password”,
database: “db_name”,
port: “3306”,
connectTimeout: 10000 // 10 seconds
});

I should’ve mentioned in my first post, you should avoid making changes to the DB directly. Can’t you use node.js with the API?

You can easily break the system by avoiding server checks/validations.

With that said, you’ll need to edit your mariaDB config files to allow access externally.

This may help: