W3docs

Resetting MySQL Root Password with XAMPP on Localhost

To reset the root password for MySQL on XAMPP, you can follow these steps.

To reset the root password for MySQL on XAMPP, follow these steps:

  1. Stop the MySQL service in XAMPP.
  2. Open a command prompt and navigate to the folder where XAMPP is installed (e.g., C:\xampp\mysql\bin).
  3. Run the following command: mysqld --skip-grant-tables
  4. Open another command prompt and navigate to the same folder as above.
  5. Run the following command to log in to MySQL as the root user: mysql -u root
  6. At the MySQL prompt, run the following commands to reset the root password:
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password';

<div class="alert alert-info flex not-prose"> Watch a course <span class="hidden md:block">Watch a video course </span> Learn object oriented PHP</div>

  1. Replace your_new_password with your desired password.
  2. Exit the MySQL prompt by running: exit
  3. Stop the MySQL server by pressing Ctrl + C in the command prompt where you started it with the --skip-grant-tables option.
  4. Start the MySQL service in XAMPP.

You should now be able to log in to the MySQL server using the new root password.

Note: By default, the XAMPP MySQL root account has no password initially.