
Wondering how to change the MySQL password in XAMPP? This question may arise if you plan to use XAMPP as a production server or for website development.
One of the main reasons why XAMPP is not recommended for production environments is its default MySQL credentials, which use the root username with no password. This makes it highly vulnerable.
If you do not change the default credentials, unauthorized users can easily access your database. That is why securing your MySQL password in XAMPP is crucial.
There are several ways to change the MySQL password depending on your operating system, whether you are using Windows or Linux.
Table of Contents
How to Change MySQL Password in XAMPP on Windows
If you have installed XAMPP on Windows, there are several ways to change the MySQL password. You can do this through phpMyAdmin, the shell, or the config.inc file.
Method 1: Using phpMyAdmin
Here is how to change the default MySQL password in XAMPP, especially for the root user, which has no password by default.
- Open the XAMPP Control Panel and click Admin under the MySQL module.
- Go to the User accounts tab.
- On the User accounts overview page, find the entries with the root username, which by default have no password. Click Edit privileges for the account you want to modify.
- Select Change password, then choose one of the following options:
(A) Manually enter a new password.
(B) Generate a password automatically.
After selecting, click Go to save the changes.
- You have successfully changed or created a new MySQL password.
Method 2: Using Shell
To change the MySQL root user password in XAMPP using Shell, follow these steps:
- Open the XAMPP Control Panel and click Shell.
- Once the command prompt window appears, enter the following command:
mysqladmin -u root password
.
- Press Enter, then input your new password.
- Press Enter again to confirm the password.
- You have successfully set up a new MySQL password.
In addition to using Shell, you can also change the MySQL password through the config.inc file.
Method 3: Using the config.inc File
The third way to change the MySQL password in XAMPP is by modifying the config.inc.php file. Follow these steps:
- Open the XAMPP folder on your Windows system.
- Navigate to the phpMyAdmin folder.
- Open the config.inc.php file using a text editor.
- Find the line for Password, enter your new password, and save the file by pressing Ctrl + S.
- Done.
These are the methods to change the MySQL password in XAMPP on Windows. If you are using Linux, check out the steps below.
Changing the MySQL Password in XAMPP on Linux
If you are using a Linux server, follow these steps to change the MySQL password in XAMPP:
- Open the XAMPP Control Panel on Linux and start XAMPP by running it as shown in the image below.
- Once the XAMPP panel appears, go to the Manage Servers tab, select MySQL Database, and click Start to run MySQL.
- Open your browser, go to /phpmyadmin/, navigate to the Database section, and open the User accounts tab.
- In the User accounts overview page, find the list of users with the root username, which by default has no password. Click Edit privileges for the account you want to modify.
- Select the Change password option. You can either (A) create your own password or (B) generate a password. Once done, click Go.
- Done. You have successfully changed or set a new MySQL password.
With this method, your MySQL database will no longer be accessible using just the root username without a password.
Successfully Changed Your MySQL Password in XAMPP?
That wraps up our tutorial on how to change the MySQL password in XAMPP on both Windows and Linux. Now, you can develop your website securely, whether it’s an LMS, CMS, or any other type of web application.
When changing the MySQL root user password, be cautious, as it may affect applications or scripts that rely on these credentials.
Before proceeding, ensure you have done thorough research, tested the changes properly, and consulted with a web development expert like Tonjoo.
Updated on February 27, 2025 by Moch. Nasikhun Amin