
If you’ve forgotten your MySQL root password on XAMPP, don’t worry — it can easily be reset. Here’s a step-by-step guide to help you reset the password and regain access to your MySQL server.
Step 1: Stop the MySQL Service
First, you need to stop the MySQL service. This will prevent any conflicts while resetting the password.
- Open XAMPP Control Panel.
- Click on the Stop button next to MySQL.
Step 2: Start MySQL in Safe Mode
Next, we’ll run MySQL without loading the privilege tables, allowing us to reset the password.
- Open a command prompt or terminal window and navigate to the XAMPP directory. This is typically located at
C:\xampp
(for Windows users). - Navigate to the MySQL folder within XAMPP:
cd C:\xampp\mysql\bin
Run the following command to start MySQL in safe mode:
mysqld --skip-grant-tables
- This command starts MySQL without loading the authentication system, which allows you to change the password without entering the current one.
Step 3: Log in to MySQL
Now that MySQL is running in safe mode, you can log in without a password.
- Open another command prompt or terminal window.
- Log into MySQL with the following command:
mysql -u root
- You should now be logged into the MySQL prompt.
Step 4: Reset the Password
Once you’re logged into MySQL, follow these steps to reset the root password:
- Select the mysql database:
use mysql;
Update the root user’s password using this query. Replace newpassword
with the password you want to set:
UPDATE user SET password=PASSWORD('newpassword') WHERE user='root';
Note: If you’re using MySQL 5.7 or newer, the query to change the password may look like this instead:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
tep 5: Restart MySQL
Now that the password has been reset, exit MySQL and restart the MySQL service in XAMPP:
- Exit MySQL:
exit;
- Go back to the XAMPP Control Panel.
- Start MySQL again by clicking Start next to MySQL.
Step 6: Log in with the New Password
Now that MySQL is running with the new root password, you can log in as usual.
- Open a command prompt or terminal.
- Log in using the new password:
mysql -u root -p