MySQL reset root password

MySQL - lost root password on slave server the other day - mysql was over-writing root password on slave - which is different for security. Uncommented

replicate-wild-ignore-table = mysql.%

on slave /etc/my.cnf after reset of password and its been fine since.

Either way, needed to reset root:

root@host ~ #  mysql -u root@localhost -p'password'
ERROR 1045 (28000): Access denied for user 'root@localhost'@'localhost' (using password: YES)
root@host ~ #  service mysqld stop
Shutting down MySQL. SUCCESS! 
root@host ~ #  mysqld_safe --skip-grant-tables &
[1] 13845
root@host ~ #  Starting mysqld daemon with databases from /var/lib/mysql

root@host ~ #  mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.NN-community-log MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> UPDATE user SET password=PASSWORD("newpassword") WHERE user="root"; flush privileges;
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
root@host ~ #  mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.0.67-community-log MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> 

From MySQL Lists - reset root password