Reset the Password of MySQL in Linux
If you had forgot the password of MySQl in your Linux System, you can always reset it. Usually, you would get the 1025 (28000) error message if you entered a wrong password or forgot to enter one.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
The following steps will help you to change you password. Use need to login as root (superuser) to do this.
- Stop the MySQl server from running. Use the Following code:
service mysql stop
- Open the mysql startup script. Add -skip-grant-tables to it. Now lets start up the mysql daemon and skip the grant tables which store the passwords.
- You should see mysqld start up successfully. Now you should be able to connect to mysql without a password.
mysql –user=root mysql
update user set Password=PASSWORD(‘new-password’) where user=’root’;
- Now, restart your MySQl with the new password. It works!