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!
2
Answers
Try this:
You can just put
%
to allow all (https://forums.cpanel.net/threads/allow-any-host-to-connect-to-mysql-remotely.189131/post-774871), or you can put the ip address where you will get the error likeError: ER_ACCESS_DENIED_ERROR: Access denied for user 'db_name'@'491.25.***.***' (using password: YES)