MySQL - Resetting Root Password

Sometime, you may forget the root password of MySQL. Below is some extracted steps to reset the root's password in Windows

1. Stop running MySQL instance. net stop mysql
2. Save the following to a text file where MyNewPass is your desired root's new password. In this example, this file will be saved at MySQL installed home's bin folder and the file calls "reset_password.txt"



UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;



3. Go to your mysql install home and run this command




mysqld-nt.exe --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini" --init-file="C:\Program Files\MySQL\MySQL Server 5.0\bin\reset_password.txt" --console



4. If MySQL start correctly, stop the server by Ctrl-C.
5. Restart the MySQL as a window service. net start mysql
6. Test your new password by mysql -u root -p. This command will prompt you for the password.

You can reset root's password for Linux too. Details can be found in
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

Comments

Popular posts from this blog

FFMPEG - Creating timelapse with FFMPEG with JPEG

MP4 File Format Part 1

RTSP - RTP over TCP