4 Ways to Change MySQL Password in XAMPP (Windows & Linux)

SHARES

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.

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.

  1. Open the XAMPP Control Panel and click Admin under the MySQL module.
  2. Go to the User accounts tab.
    How to Change MySQL Password in XAMPP Properly
  3. 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.
    How to Change MySQL Password in XAMPP Properly
  4. 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.
    How to Change MySQL Password in XAMPP Properly
  5. 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:

  1. Open the XAMPP Control Panel and click Shell.
    How to Change MySQL Password in XAMPP Properly
  2. Once the command prompt window appears, enter the following command: mysqladmin -u root password.
    How to Change MySQL Password in XAMPP Properly
  3. Press Enter, then input your new password.
    How to Change MySQL Password in XAMPP Properly
  4. Press Enter again to confirm the password.
    How to Change MySQL Password in XAMPP Properly
  5. 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:

  1. Open the XAMPP folder on your Windows system.
    How to Change MySQL Password in XAMPP Properly
  2. Navigate to the phpMyAdmin folder.
  3. Open the config.inc.php file using a text editor.
  4. Find the line for Password, enter your new password, and save the file by pressing Ctrl + S.
    How to Change MySQL Password in XAMPP Properly
  5. 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:

  1. Open the XAMPP Control Panel on Linux and start XAMPP by running it as shown in the image below.
    How to Change MySQL Password in XAMPP Properly
  2. Once the XAMPP panel appears, go to the Manage Servers tab, select MySQL Database, and click Start to run MySQL.
    How to Change MySQL Password in XAMPP Properly
  3. Open your browser, go to /phpmyadmin/, navigate to the Database section, and open the User accounts tab.
    How to Change MySQL Password in XAMPP Properly
  4. 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.
    How to Change MySQL Password in XAMPP Properly
  5. Select the Change password option. You can either (A) create your own password or (B) generate a password. Once done, click Go.
    How to Change MySQL Password in XAMPP Properly
  6. 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.

website

Updated on February 27, 2025 by Moch. Nasikhun Amin

Lets Work Together!

Create your ideal website with us.