const mysql = require("mysql2/promise");const pool = mysql.createPool({ host: "host.mysql.database.azure.com", user: "user", password: "password", database: "db", port: 3306, waitForConnections: true, connectionLimit: 10, queueLimit: 0,});async function init() { // Initialize the connection try { const connection = await pool.getConnection(); console.log("Connected to the MySQL server."); connection.release(); } catch (error) { console.error(`Error connecting to the MySQL server : ${error.message}`); }}init();
when i run this code in win11 "Connected to the MySQL server". but in wsl2 (ubuntu) "Error connecting to the MySQL server" why this is happening? and how can i fix this
mysql server hosted on Azure cant be accesed in wsl2(ubuntu) but can be accesed in win11
but when i tried to connect with "mysql --host=host.mysql.database.azure.com --user=user --password=password" in wsl2 its working