- Open the XAMPP Control Panel and stop the MySQL service if it is running.
- Clicck the "Config" button next to the MySQL module.
- Select "my.ini" from the list — this file resides in the
XAMPP\mysql\bindirectory. - Locate the
[mysqld]section in the configuration file. - Add the line
skip-grant-tablesunder that section. - Save the changes and close the file.
- 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-tablesfrommy.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.iniare 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.