question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Err access denied, not sure what else to try

See original GitHub issue

Hello, I’m using mysql in my node app and I"m not sure how to get past this error:

code: 'ER_ACCESS_DENIED_ERROR',
  errno: 1045,
  sqlMessage:
   'Access denied for user \'magento\'@\'me.localtestdomain\' (using password: YES)',
  sqlState: '28000',
  fatal: true

On the target machine (remote machine), I’m able to connect using mysql workbench without issues. I can even connect using mysql with the port being a ssh-tunnel no problem. But i get that error above when i try to connect straight like I’m doing in mysql workbench. Given i can connect using mysql workbench without ssh, the machine is listening on all interfaces. I have the config set to bind 0.0.0.0.

As root if i run mysql> SHOW GRANTS FOR 'magento'@'%';, i get:

+----------------------------------------------------------------+
| Grants for magento@%                                           |
+----------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'magento'@'%' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `database`.`magento` TO 'magento'@'%'  |
+----------------------------------------------------------------+
2 rows in set (0.00 sec)

Not sure how to remove the second line, but the first line should be enough to get me back working (unless i’m wrong). I’ve ran mysql> FLUSH PRIVILEGES;, manually restarted mysql with systemctl restart mysql.service and even rebooted the remote server. I’m still unable to get this module working for a direct connection.

Partial script

const connectionParameters = () => {    
  return mysql.createConnection({
    host: <remote ip>,
    port: 3306,
    user: 'magento',
    password: 'password',
    database: 'magento'
  });
};

let connection = connectionParameters();
// connection.connect();
connection.connect(function (err) {
  if (err) {
    console.log(err);
    console.log('Error', err.code) // 'ECONNREFUSED'
    console.log('Error', err.sqlMessage)
    console.log'Fatal', err.fatal)
  }
})

let query = 'SELECT * FROM core_config_data';
connection.query(query, function (error, results, fields) {
  if (error) return reject(error);
  console.log(JSON.stringify(results, null, 2))
});
connection.end();

It’s Ubuntu 18.04 LTS, ufw has allow on port 3306. I’m lost. Looked at similar issues and the people that opened the tickets often didn’t reply or didn’t give the information requested while you all were trying to help. Hopefully you will be able t help me. I’ve provided details above and can provide more.

Any ideas on what to do?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
travis5491811commented, Feb 6, 2019

@travis5491811, that’s strange. can you login into the server as root and deleting the user from mysql, re-create them, grant privileges and flush privileges?

2reactions
travis5491811commented, Feb 6, 2019

Umm, that worked. Not sure why but ok.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Access Denied" or other errors when you access or work with ...
Issue 1: I receive an "Access Denied" error message when I try to access or work with files and folders · Press and...
Read more >
Fix “Access Denied, You Don't Have Permission To Access on ...
These easy-to-follow solutions will help you fix the "Access denied, you don't have permission to access on this server” error in Windows 10....
Read more >
Getting the Access denied Windows 11 error? Try these fixes!
Snap! Getting the Access denied Windows 11 error ? Try these fixes!This small issue can be very annoying at times, but don't worry!...
Read more >
Troubleshoot 403 Access Denied errors from Amazon S3
My users are trying to access objects in my Amazon Simple Storage Service (Amazon S3) bucket, but Amazon S3 is returning the 403...
Read more >
Troubleshooting access denied error messages - AWS Identity ...
Most access denied error messages appear in the format User user is not authorized to perform action on resource because context . In...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found