Home >Database >Mysql Tutorial >How to Reset a Lost MySQL Password for PHPMyAdmin in WAMP?

How to Reset a Lost MySQL Password for PHPMyAdmin in WAMP?

Linda Hamilton
Linda HamiltonOriginal
2024-11-14 19:41:02815browse

How to Reset a Lost MySQL Password for PHPMyAdmin in WAMP?

Retrieving Access to a Lost MySQL Password for PHPMyAdmin in WAMP

Problem:

A user has changed the password for their 'root'@'localhost' account in PHPMyAdmin but has subsequently lost access to PHPMyAdmin due to forgetting the new password. The methods suggested in previous forums (such as resetting the password via command line) have not been successful due to a lack of privileges.

Solution:

Here is a step-by-step process to reset the MYSQL 'root' password:

  1. Stop the MySQL service: Go to WAMPSERVER, select MySQL, and choose "Service" > "Stop Service."
  2. Edit the my.ini file: Go to WAMPSERVER > MySQL > my.ini.
  3. Locate the [wampmysqld] section: Add the line "skip-grant-tables" directly below this section heading.
  4. Restart the MySQL service: Go to WAMPSERVER > MySQL > Service > "Start/Resume Service."
  5. Open the MySQL console: Go to WAMPSERVER > MySQL > MySQL Console.
  6. Reset the root user password:

    • Pre MySQL version 5.7: Enter "UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES;"
    • Post MySQL version 5.7: Enter "UPDATE mysql.user SET authentication_string=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES;"
  7. Exit the MySQL console: Type "quit" at the mysql command prompt.
  8. Stop the MySQL service again: Go to WAMPSERVER > MySQL > Service > "Stop Service."
  9. Remove the skip-grant-tables parameter: Edit the my.ini file, locate the [wampmysqld] section, and remove the "skip-grant-tables" line.
  10. Restart the MySQL service: Go to WAMPSERVER > MySQL > Service > "Start/Resume Service."

Optional: If desired, modify the settings so that the root user account does not have an expiring password by running the following query in the MySQL console: "ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;"

By following these steps, users can regain access to PHPMyAdmin using the 'root' user ID and their newly assigned password.

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

Statement:
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