Reset MySQL Root Password in XAMPP

  1. Open the XAMPP Control Panel and stop the MySQL service if it is running.
  2. Clicck the "Config" button next to the MySQL module.
  3. Select "my.ini" from the list — this file resides in the XAMPP\mysql\bin directory.
  4. Locate the [mysqld] section in the configuration file.
  5. Add the line skip-grant-tables under that section.
  6. Save the changes and close the file.
  7. Return to the XAMPP Control Panel and restart the MySQL service.

Now open a terminal or command prompt. Navigate to the MySQL bin directory:

cd C:\xampp\mysql\bin

Launch the MySQL client without authentication:

mysql -u root

Once inside the MySQL prompt, update the root passsword using the following command:

UPDATE mysql.user SET authentication_string = PASSWORD('new_secure_password') WHERE User = 'root';

Replace new_secure_password with your desired password. Then reload the privilege tables:

FLUSH PRIVILEGES;

Exit the MySQL client:

exit;

Stop the MySQL service again in the XAMPP Control Panel. Reopen the my.ini file and remove the skip-grant-tables line you added earlier. Save the file.

Restart MySQL one final time. You should now be able to log in with your new password using:

mysql -u root -p

Handling Common Errors

Error: "The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement"

This occurs because skip-grant-tables disables all privilege checks, making password updates impossible. To resolve:

  • Stop the MySQL service.
  • Remove skip-grant-tables from my.ini.
  • Restart MySQL normally — authentication will be re-enabled.
  • Try the password update again.

Error: "MySQL server has gone away" or "Can't connect to localhost"

These indicate a connection failure. Check:

  • Whether the MySQL service is actually running in the XAMPP panel.
  • If the port (default 3306) is not blocked by a firewall or occupied by another process.
  • That no syntax errors in my.ini are preventing MySQL from starting properly.

If MySQL fails to start after editing my.ini, revert the changes and validate the file’s syntax before retrying.

Tags: MySQL xampp password-reset my.ini skip-grant-tables

Posted on Mon, 14 Sep 2026 16:13:16 +0000 by smordue