MySQL root password recovery

Quick steps to recovering (aka resetting) the root password on MySQL:

1. Find the PID of the mysql process
ps -aef | grep mysqld
root 11889 11090 0 Jun 10 ? 0:00 /bin/sh bin/safe_mysqld
mysql 11909 11889 0 Jun 10 ? 525:44 /local/mysql-5.0.45-solaris10-i386/bin/mysqld --basedir=/local/mysql-5.0.45-sol

2. Kill the mysql process; kill 11909 Make sure not to use a -9…
3. Create a file that the user that runs mysql can access; and place in it the following:

UPDATE mysql.user SET Password=PASSWORD('FozzyBear') WHERE User='root';

4. Start mysql: mysqld_safe --init-file=/path/to/file &
5. Try to connect as root now, if it works, delete the temp file; stop and restart mysql.

Granted, the above can be done by any one who knows the password for the account that MySQL runs under, or has root access to the machine. I usually leave the mysql UNIX account in a locked state, so no one can su to it, so you have to have access to root, to be able to su to it.