I built a MERN app (used mysql instead of MongoDB)
* I deployed it on the VPS (Ubuntu 24.04)
* everything seems okay but when I try to check the logs of my backend using
pm2
package it gives me kind of weird picture: first it gives me errors and then seems it is connected.
* This is my db connection code
const mysql = require('mysql2');
const dbHost = "127.0.0.1";
const databaseConnection = () => {
const db = mysql.createConnection({
host: '127.0.0.1',
user: 'Test',
password: 'Iwillnottell',
database: 'Test',
});
db.connect(err => {
if (err) throw err;
console.log('MySQL Connected...');
});
return db; };
module.exports = databaseConnection();

Asked by Shayan Kanwal
(99 rep)
Dec 9, 2024, 11:05 AM
Last activity: Dec 9, 2024, 01:17 PM
Last activity: Dec 9, 2024, 01:17 PM