Changing MySQL 5.0 root password in FreeBSD 7.2-RELEASE

So you have forgotten your mysql root password and you now have no access on you mysql server.

Here are the steps to set a new root password. (you need root privileges)

1. Stop the mysql database server
/usr/local/etc/rc.d/mysql-server stop

2. Start mysql and bypass the authentication
/usr/local/libexec/mysqld --skip-grant-tables --skip-networking --user=root &

3. Log in to mysql (without password)
mysql -h localhost -u root

4. When you’re logged and in the mysql command prompt, you set the password.
use mysql;
update user set password=password( 'yournewpassword' ) where user='root';
flush privileges;
exit;

5. Stop mysql by process id (PID)
ps ax | grep mysql
Result
34666 p0 I 0:01.53 /usr/local/libexec/mysqld --skip-grant-tables --skip-networking --user=root &
kill -TERM 34666

5. Start mysql via /usr/local
/usr/local/etc/rc.d/mysql-server start

6. Log to mysql and use your new root password
mysql -h localhost -u root -p

7. Enjoy