MySQL-Reset-Root
From DevRandom
This method requires only 1 restart of MySQL & privileges are never opened to all connections (local or network) unlike the --skip-grant option
Edit my.cnf and add
init_file=/tmp/mysql.init
Edit mysql.init and add the following
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newsecurepassword');
FLUSH PRIVILEGES;
Restart MySQL
Remove or comment out init_file=/tmp/mysql.init from my.cnf file






