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

前端 未结 29 4269
北恋
北恋 2020-12-13 13:26

I am attempting to connect to mySQL through a NodeJS file, but I receive the following error:

{ Error: ER_ACCESS_DENIED_ERROR: Access denied for user \'root\         


        
29条回答
  •  独厮守ぢ
    2020-12-13 13:59

    I was facing same error on mac, however whenever I run same code on windows machine it was working absolutely good, without any error. After spending 2 days I found solution.

    Below are the steps I followed.

    1. to your project folder in terminal and run "sudo su -" command

    e.g. Avi-MBP:projectDirectory avisurya$ sudo su -

    1. it will as password e.g. Password: enter your mac user password

    2. Now you will be in root e.g. Avi-MBP:~ root#

    3. now again go to project directory e.g. Avi-MBP:~ root# cd /Users/avisurya/projectDirectory

    4. now start node application e.g. in my case "node server.js"

提交回复
热议问题