I am trying to connect to a mysql server with the mysql
library. I used the following code:
const mysql = require('mysql');
const connection = mysql.createConnection({
host : 'mysql.panamath.org',
user : <username>,
password : <password>,
database : <database>
});
connection.connect(err => {
if (err) return console.log(err);
console.log("Success connecting to database");
});
When I visit mysql.panamath.org
, I am redirected to here, where my credentials work fine. However, when I run this connection, I get this error:
Error: ER_ACCESS_DENIED_ERROR: Access denied for user <username>@'129-2-181-10.wireless.umd.edu' (using password: YES)
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlMessage: "Access denied for user <username>@'129-2-181-10.wireless.umd.edu' (using password: YES)",
sqlState: '28000',
fatal: true
It seems to be connecting to '129-2-181-10.wireless.umd.edu'
. Interestingly, when I deployed through heroku, it was the same error except it was trying to connect to 'ec2-3-89-96-69.compute-1.amazonaws.com'
. I also tried to connect through the terminal:
$ mysql -h mysql.panamath.org -u <username> -p
Enter password:
ERROR 1045 (28000): Access denied for user ...
with the same result.
What's going on here? Why can I connect through the website but not in my code? Is there another module or function for connecting to phpMyAdmin sites, or is the phpMyAdmin site connected to the server somehow?