See this article Change or reset the password of a macOS user account - Apple Support
See another method -
Shut down the system through apple logo , press command , R and power key simultaneously , release the keys when apple logo appears , the bar starts loading let it be completed , select the language as English .
Take cursor on top menu bar > click on utilities > click on terminal in the terminal window execute a command resetpassword and click on enter key .
A window appears , select your admin name , enter the password for Apple ID .
Two options will be shown ( a ) previous ( b) next , click on next
Select your user account , you have to press forcefully on the trackpad to get it selected .
Some fields will appear .
New password ……
Verify password ……
Hint ……
Fill up the credentials ( enter a new password ) and click on next then you have to click on restart .
The Mac will restart but you will see pop ups as this Mac can’t connect to iCloud because a problem with your mail address open iCloud preferences for problem.
You will see two options ( a ) Later ( b) iCloud preferences
And on the top right corner web mail ( could be gmail ) pop up will be there stating google password required enter your password for gmail address and showing close and continue .
Open system preferences > click on iCloud you will see the box for keychain is unchecked, so check mark the box a small pop - up will come on the screen after a while to enter iCloud verification code so enter it .
Make sure your trusted mobile is opened , after a while six digit code will come through sms on the mobile .Enter the six digit code on the next pop up .
You will see iCloud Keychain is setting up and a small circle is rotating the box for keychain is configured with iCloud server .
Now , on the top right corner of the desktop a google pop up is showing , click on continue a window will appear enter your gmail password so that is also configured .
Open airport utility through spotlight , click on base station you will see that password is empty , click on edit a pop up window will appear enter the base station or wireless network password .
Keep the box checked for remember this password in my keychain .
The settings will go to default .
Open safari and you have to reset the homepage once again ( open safari preferences click on General , enter the search engine link and take cursor on history > click on home and close safari window , a pop up window will appear change home page , click on it ) .
Lastly shut down the system when login window appears you can enter admin name and " new password " in the fields .
Note : If you enter in user library ( click on finder Go > hold option key and click on library ) > Find a folder keychains you will see login keychain is renamed and its a confirmation that login password has been changed and always be careful once login password is changed don’t delete login_rename …Keychain-db or previous login.Keychain-db from user library > keychain folder , if it is deleted the keychain application will be corrupted .