'How to connect to cpanel mysql database from localhost
I am trying to connect to the mysql database from my express server in cpanel (the databse and server are both in cpanel) , I already added a user, and I'm trying to connect via localhost but this ain't working below is the code:
const db = mysql.createPool({
host: "localhost",
user: \\user\\,
password: \\password\\,
database: "ts34mpr_SCMP",
dateStrings: true,
});
The request isn't reaching the databse although I added the user with all privileges and the user with password are 100% correct. Any help please? Thank you!
Solution 1:[1]
Try this:
const mysql = require('mysql');
const connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '',
database: 'cpanel'
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Akshat Patel |
