Untitled
unknown
plain_text
a year ago
481 B
7
Indexable
const mysql = require('mysql2');
require('dotenv').config();
const db = mysql.createConnection({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
});
db.connect((err) => {
if (err) {
console.error('Error connecting to the database:', err);
process.exit(1); // Exit the process if the DB connection fails
}
console.log('Connected to MySQL');
});
module.exports = db;Editor is loading...
Leave a Comment