FreeBSD – Lost MySQL Password / restore mysql password / reset mysql password

If you lost / forgot your MySQL password you can restore it by connecting to the host with SSH.
Next you add the following line to you /etc/rc.conf.
mysql_args="--skip-grant-tables --skip-networking"

Then restart MySQL
# /usr/local/etc/rc.d/mysql-server restart

Connect with MySQL
# mysql -u root mysql
Then type the below command:
UPDATE mysql.user SET Password=PASSWORD(‘new password’) WHERE USER=’root’;
exit

Now remove the line you added from rc.conf and restart mysql once again.
You will now be able to access mysql / phpmyadmin