JA
/
EN

How to Set the XAMPP root Password to root to Match MAMP

  • 開発環境
  • Windows

Note: The screenshots in this article were captured in a Japanese-language Windows environment. Menu and setting names may differ slightly in an English-language installation.

For the Mac version of MAMP's MySQL, the default username and password are both root. In the MariaDB that ships with the Windows version of XAMPP, in the verification environment used here, root@localhost has no password set. As-is, you would need to switch connection information when using the same PHP application or configuration file on Mac and Windows.

In this article, to align the connection information for local development, we will change the XAMPP root@localhost password to root and update phpMyAdmin's config.inc.php accordingly.

Verification itemsContent
Windows environmentXAMPP 8.2.12、MariaDB 10.4.32、phpMyAdmin 5.2.1
environment to prepareMac version MAMP
usernameroot
passwordroot
PurposeLocal development environment only

If XAMPP has not been installed, please first follow "How to install the Windows version of XAMPP." To edit config.inc.php, you can use a text editor such as the one covered in "How to install VSCode."

Reasons for aligning MAMP and XAMPP connection information

According to the MAMP official documentation, the default MySQL connection information for the Mac version of MAMP is shown below.

ItemMAMP default value
usernameroot
passwordroot

By setting the same value for XAMPP on the Windows side, you can share the user name and password when moving PHP applications between local environments. However, MAMP and XAMPP may have different default ports, sockets, etc., so not all connection information is the same.

Points to note before setting

If you change your password, you will no longer be able to connect from PHP apps or database management tools that use the old connection information. Check the following before proceeding:

  • Back up the required databases
  • Only use MariaDB and phpMyAdmin from localhost
  • Don't use root as the connecting user for production apps
  • Disallow external connections through Windows Firewall or MariaDB
  • Check if an existing app is using an empty root password

XAMPP is a package for local development. The Apache Friends FAQ for Windows states that it is not intended for production use, and that exposing phpMyAdmin externally carries significant risk.

Check the current root account

1. Start Apache and MySQL in the XAMPP Control Panel.

2. Open http://localhost/phpmyadmin/ in your browser.

3. Check the "Database Server" field on the top page.

Screenshot from the Japanese-language environment

The verification environment for this article has the following configuration.

Itemvalue
server127.0.0.1 via TCP/IP
Server typeMariaDB
server version10.4.32-MariaDB
current userroot@localhost
PHP version8.2.12

4. Open "User Account" in the top menu.

5. Check the Password column for root@localhost.

Screenshot from the Japanese-language environment

In MariaDB, an account is a combination of username and connection source host. This article changes root@localhost; root@127.0.0.1 and root@::1 will be treated as separate accounts.

Change root password to root

1. Click Edit Permissions for root@localhost.

2. Open the "Change password" tab on the permission editing screen.

Screenshot from the Japanese-language environment
Screenshot from the Japanese-language environment

3. Select Password:.

4. Enter root in both "Password" and "Re-enter"

Screenshot from the Japanese-language environment

phpMyAdmin's strength display shows that the password is weak. This is as expected and is a local-only setting for compatibility with MAMP defaults.

5. Password hashing does not change from the default value in the verification environment unless the app specifies a different method.

6. Click Run.

7. Confirm the message that the password for root@localhost has been changed.

Why is Access denied displayed?

Immediately after changing your password, you may receive the following error:

Screenshot from the Japanese-language environment
mysqli::real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO)

This happens because XAMPP's phpMyAdmin was using config authentication with an empty password, which no longer matches the new root password on the MariaDB side. If the password change itself was successful, update the connection information on the phpMyAdmin side using the following steps.

Update config.inc.php in phpMyAdmin

1. Open C:\xampp\phpMyAdmin in Explorer.

2. Before editing, create a backup of config.inc.php.

3. Open config.inc.php in a text editor.

Screenshot from the Japanese-language environment

4. Look for authentication settings. Line numbers vary depending on your environment.

Screenshot from the Japanese-language environment

The example before the changes is as follows:

$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

5. Set the password to root and disable passwordless connections.

$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

6. Save the file.

With config authentication, the password is saved in plain text in the configuration file, and login happens automatically. This method suits our purpose of using the same credentials for local development on MAMP and XAMPP. If you're not using a shared PC or an externally exposed environment and need stronger authentication, check the phpMyAdmin official authentication mode documentation and consider cookie authentication.

Check the operation after setting

1. Reload http://localhost/phpmyadmin/ in your browser.

2. Verify that the Access denied error disappears.

3. Make sure you can open the database list and the root@localhost permissions screen.

Screenshot from the Japanese-language environment

Next, check if you can connect from a local app using the same credentials.

username: root
password: root

If you cannot connect, also check the hostname, port number, and host part of the target root account. Depending on the configuration, MAMP often uses port 8889, while XAMPP generally uses 3306, so even with the same passwords, the port numbers may differ.

Reference materials

Summary

ItemSetting details
purposeUnify local DB credentials between MAMP on Mac and XAMPP on Windows
MariaDB accountroot@localhost
Setting passwordroot
phpMyAdmin authenticationconfig authentication
config.inc.phpPassword changed to root, AllowNoPassword changed to false
Usage rangelocalhost limited development environment

With this setting, MAMP and XAMPP can share the same root / root connection information. However, this setup is for local-development portability only. Do not use it in an externally exposed environment — set up dedicated users and strong passwords for each purpose there.

Share this article