You first need to boot your Mac into single user mode by booting it up while holding down the “command+s” keys.
Once your in Single User Mode type in
mount -uw /
That will mount your Mac hard drive. Now run
launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist
and now you can change the password. Replace “username” and “password” with the username for the user and the new password.
dscl . passwd /Users/username password
Now you can reboot the machine
reboot
and log in with the new password.