The root password is essential to system security and should always be safeguarded. Unfortunately, anything can be lost, and a password is no exception.
The first step to changing a lost password is to boot into single-user mode. For more information on booting into single user mode, please see the following :
Article 30837: "Mac OS X Server: Booting Into Single-user Mode"
The system starts up, displaying a series of messages. When startup is complete, you see the single-user prompt "#." Type the following command at the prompt:
sh /etc/rc
You see a series of messages appear on the screen as the rc shell script executes. During this process, NetInfo is started. You won't see a shell prompt after these messages unless you press the Return key.
Set the root password. Enter the following command at the prompt:
passwd root
You're prompted twice for the new password.
Restarting
Once the password has been changed the system must be rebooted. To restart the computer, type the following command at the prompt:
shutdown -r now
The argument "now" in the commands above can be replaced with "+n", where "n" is the number of minutes to give other users time to log out.
Warning: You must restart the system as mentioned above. Do not boot into multiuser mode. If you do, you will start duplicate system services, which will cause a number of issues.