Home > Database > Mysql Tutorial > How to Recover Lost MySQL Password for PHPMyAdmin on WAMP?

How to Recover Lost MySQL Password for PHPMyAdmin on WAMP?

Barbara Streisand
Release: 2024-11-16 11:57:02
Original
1040 people have browsed it

How to Recover Lost MySQL Password for PHPMyAdmin on WAMP?

Regaining Access to Lost MySQL Password for PHPMyAdmin on WAMP

You're facing a challenge accessing PHPMyAdmin after changing the password for the 'root'@'localhost' account. Despite using methods mentioned elsewhere, you've lost the new password and are unable to use the MySQL Console.

Solution:

To regain access, follow these steps:

1. Stop MySQL Service:

  • Launch WAMP and navigate to MySQL > Service > Stop Service.

2. Edit my.ini File:

  • Click WAMP > MySQL > my.ini.
  • Locate the [wampmysqld] (for 32-bit) or [wampmysqld64] (for 64-bit) section.
  • Add "skip-grant-tables" directly after the section heading.

3. Restart MySQL Service:

  • Click WAMP > MySQL > Service > Start/Resume Service.

4. Open MySQL Console:

  • Navigate to WAMP > MySQL > MySQL Console.

5. Reset Root Password:

  • Enter the following commands at the mysql> prompt:

    • Pre MySQL version 5.7:

      • UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
      • FLUSH PRIVILEGES;
    • Post MySQL version 5.7:

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

Note: Replace 'MyNewPass' with the new password you want to set.

6. Exit MySQL Console

  • Type 'quit' at the mysql> prompt.

7. Stop MySQL Service:

  • Click WAMP > MySQL > Service > Stop Service.

8. Remove skip-grant-tables Parameter:

  • In the my.ini file, remove the "skip-grant-tables" parameter.
  • Save the changes.

9. Restart MySQL Service:

  • Click WAMP > MySQL > Service > Start/Resume Service.

10. (Optional) Prevent Password Expiration:

  • Open MySQL Console.
  • Enter the following command:

    • ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;

11. Log in to PHPMyAdmin

  • Access PHPMyAdmin with the username 'root' and the new password you set.

Remember, leaving the "skip-grant-tables" parameter in the my.ini file is a security risk. Remove it immediately after resetting the password.

The above is the detailed content of How to Recover Lost MySQL Password for PHPMyAdmin on WAMP?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template