How do I recover the administrator or root password on OS X?
Boot to OS recovery, internet recovery or on older systems, with a Mac OS X DVD, then there's an option to change passwords.



You can follow an how-to here.