Reset MySQL root Password
If you have set a root password for MySQL previously, but have forgotten what it was, you can reset the password without much hassle.
Reset root password on Windows Systems
- Logon to your system as an Administrator
- Stop the MySQL service
- Create a text file with the following SQL command.
UPDATE mysql.user SET Password=PASSWORD('NEW_PASSWORD') WHERE User='root'; FLUSH PRIVILEGES; - Save the file as mysql-reset.txt under C:
- Open a Windows Command Prompt
- Start the MySQL server with the –init-file option
C:mysqlbinmysqld-nt --init-file=C:mysql-reset.txt
If you have installed MySQL to a location other than c:mysql, adjust the above command accordingly
- Delete the file created in step 3
- Stop the MySQL server from the Command Prompt and restart the MySQL service
You should now be able to connect to the MySQL server using your new password as root.
Reset root password on UNIX Systems
- Logon to the system as root or as the user that the MySQL daemon runs as
- Stop the MySQL daemon process
- Create a text file with the following SQL command.
UPDATE mysql.user SET Password=PASSWORD('NEW_PASSWORD') WHERE User='root'; FLUSH PRIVILEGES; - Save the file as mysql-reset.txt under your home directory
- Start MySQL daemon with the –init-file option
mysqld_safe --init-file=~/mysql-reset.txt &
- Delete the file created in step 3
- Kill the MySQL daemon and restart the MySQL daemon
You should now be able to connect to the MySQL server using your new password as root.








Comments
No Comments Yet
You can be the first to comment!
Leave a Comment