If you ever forget the root password, you can reset it with this sequence of commands:
su cd /etc/init.d ./mysql stop mv mysql mysql.orig cp mysql.orig mysql emacs mysql
Change the line in the startup section that reads:
/usr/bin/mysqld_safe ...
To read:
/usr/bin/mysqld_safe --skip-grant-tables ...
Save the file, exit the editor, and restart the mysql server:
./mysql start
Run the MySQL client from the command prompt:
/usr/local/mysql/bin/mysql
Issue the following statements in the mysql client. Replace the MyNewPass with the password that you want to use:
update mysql.user set Password=password('MyNewPass') where User='root'; flush privileges; quit
Stop the mysql server and restore the original startup script:
./mysql stop rm -f mysql mv mysql.orig mysql
Restart the mysql server:
./mysql start
You should now be able to login to mysql using the root password:
/usr/local/mysql/bin/mysql -uroot -pMyNewPass