When a Mac computer is first turned on, it runs a first-time setup assistant to help you add an new account to the computer.
You need it in order to use the machine. However, that same method can be used to add another administrator account to any mac if you have physical access to it.
It’s a security threat if you lose your mac, but you can protect against it by having a firmware password on your Mac.
Here’s how to run the first-time setup assistant again:
Boot the computer into Single-User Mode (CMD+S)
In the terminal, type:
mount -uw / and press return
rm /var/db/.AppleSetupDone and press return
shutdown -h now and press return,
The Mac will Shut Down, and then you can press the power button and when it boots it will automatically run the Apple Setup screen again, allowing you to add an administrator account to a computer.
After That’s all done and you are in the Mac OS Operating system, you can now go and change the passwords to the other Users that you have on your device, so for that, just click on the Apple Logo on the Top Left of your screen and then click on “System Preferences”, a Window should appear and in the bottom you will now click on a Icon that’s named “Users and Groups” and it should take you to another window that shows you all the users that you have on your device. It will have the user that was created now and below it should appear the previous accounts. Now you will notice that it appears grayed out, that is normal, you will have to click on the padlock on the bottom left of this window to unlock and then it will ask for your username and password, so it is just a matter of filling that out with the one that you just created.
After that the users will not be grayed out anymore, so just click on the user that you need to change the password, and then click on the right where it says to “Reset Password”, a new pop-up window should appear asking for a new password and password hint, just fill that out, Restart the computer and you will be able to log in will no problem.
I hope it helped.