Software⏱️ 2 min read📅 2026-05-31

How to Fix: NodeJS/mySQL - ER_ACCESS_DENIED_ERROR Access denied for user 'root'@'localhost' (using password: YES)

Check MySQL password and privileges.

Quick Answer: Verify the MySQL root user password and ensure the correct privileges are set.

The ER_ACCESS_DENIED_ERROR error occurs when the MySQL server is unable to authenticate the user attempting to connect. In this case, the error message indicates that access has been denied for the 'root' user at 'localhost' using a password.

💡 Why You Are Getting This Error

  • [Cause]

🚀 How to Resolve This Issue

Method 1: Check MySQL Configuration

  1. Step 1: Open the my.cnf file located in the /etc/mysql/mysql.conf.d/ directory.

Method 2: Change MySQL Root Password

  1. Step 1: Use the following command to change the root password: mysql -u root -p

💡 Conclusion

To resolve this issue, you can either check your MySQL configuration or change the root password. If you are still facing issues, ensure that the correct port is being used and the connection settings are correct.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions