Shantanu Sen
Shantanu Sen

Reputation: 221

Reset MYSQL root password

I have windows 7 and MYsql is installed on that. I am facing now and then one big issue ... very frequently the root passwords locks and i get the below error SQL Error (1045): Access denied for user 'root'@'localhost' (using password: YES)

Now to resolve this i use the below steps

  1. Stop running Mysql service first (Administrative tools > Services )

  2. Open command prompt (cmd) and reach the directory (using CD command) where Mysql bin is installed (eg: C:/Program Files/Mysql/bin)

  3. type mysqld.exe -u root –skip-grant-tables and press enter (don’t close this command prompt)

  4. Open new command prompt and reach the same Mysql bin directory

  5. type mysql and press enter (This time, it never prompts for any passwords and you can enter mysql console)

  6. type command use mysql to switch your database into mysql

  7. Execute the usual command to change password for rootUPDATE user SET Password = PASSWORD(‘your_new_password’) WHERE User = ‘root’;

  8. Close the command prompts and go to services , start mysql. Now you can login with your new root password

but still this === mysqld.exe -u root –skip-grant-tables does not respond....

Please help with the root cause and resolution

Upvotes: 1

Views: 1934

Answers (1)

Lokesh kumar Chippada
Lokesh kumar Chippada

Reputation: 1411

Follow these steps to hard reset:

  1. Stop Mysql service from task manager

  2. Create a text file and paste the below statement

MySQL 5.7.5 and earlier:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yournewpassword');

MySQL 5.7.6 and later:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'yournewpassword';
  1. Save as mysql-init.txt and place it in 'C' drive.

  2. Open command prompt and paste the following

    C:> mysqld --init-file=C:\mysql-init.txt

Upvotes: 1

Related Questions