0

I reset my MySQL password using cmd commands from this guide.

cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
mysqld
--defaults-file="C:\\ProgramData\\MySQL\\MySQL Server 8.0\\my.ini"
--init-file=C:\\Users\\<username>\\resetMYSQL.txt

resetMYSQL contains a command to change password

ALTER USER 'root'@'localhost' IDENTIFIED BY '<myNewPassword>';

Now, it turned out I have to keep running the mysqld command above to start my server or else I'll get this error. If I run the command again I can flawlessly run my server until I terminate it.

This is the error. It's ECONNREFUSED. Node's error

I think my password is already reset, because apart from the command line, I also run ALTER USER in Workbench after I got access to it while the cmd is running.

Btw, before this I can just start my server using Node and Sequelize and didn't have to start server elsewhere or set anything beforehand

I'm not sure what is the problem here, so I don't know which keyword I should look up on Google. I googled the error code, but those cases seems unrelated to mine. I'd be glad if you can explain me what's going on.

3
  • 1
    Is there a reson that you dont configor MySQL to run as a service? Commented May 29, 2020 at 15:21
  • This Should give you a clue how it should be done Commented May 29, 2020 at 15:22
  • Could you please explain it further? I'm still lost here. I didn't use Wamp. I think my password is already reset, because apart from the command line, I also run ALTER USER in Workbench after I got access to it while the cmd is running. Btw, before this I can just start my server using Node and Sequelize and didn't have to start server elsewhere or set anything beforehand. Thanks Commented May 29, 2020 at 15:40

1 Answer 1

1

The nodejs error message you showed us, a ECONNREFUSED message with a traceback, shows the your mysql database server program was not running when your nodejs program tried to connect to it. Nodejs reaches out to MySQL via TCP/IP. TCP/IP responds "I don't know any MySQL." Specifically, it responds "ECONNREFUSED on port 3306," meaning "nothing on this machine accepts connections on MySQL's port."

nodejs does not start the mysql software for you. It connects to it and uses it.. MySQL has to be running already for that work.

Ordinarily, software like mysql runs in the form of a operating system service; a background process that runs all the time on the machine to await requests).

And, ordinarily, you don't provide init files to MySQL to do things like change passwords, except just once, if you must, to rescue something broken. In your case it looks like you forgot your MySQL password, so you needed to use an init file to rescue yourself. Once the password is reset, stop using that init file.

Explaining how to make MySQL run as a service on your machine is beyond the scope of a Stack Overflow answer. But the installers for MySQL, on almost every operating system, set it up to run as a service automatically. It's generally useless otherwise.

Sign up to request clarification or add additional context in comments.

1 Comment

I learned a lot from your kind comment. I install MySQL using an installer, so I figure out that I should just restart my pc to start MySQL via Windows Service. Now, it work just like before. Many Thanks! I appreciate your help a lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.