XAMPP MySQL Shutdown Unexpectedly: How to Fix MySQL Port 3306 to 3307 and phpMyAdmin Not Opening

XAMPP MySQL Shutdown Unexpectedly: How to Fix MySQL Port 3306 to 3307 and phpMyAdmin Not Opening

If XAMPP shows “MySQL shutdown unexpectedly”, one common solution is changing the MySQL/MariaDB port from 3306 to 3307 when another application is already using port 3306.

However, after changing the port, many users find that phpMyAdmin no longer connects to MySQL.

This happens because MySQL is now running on port 3307, while phpMyAdmin may still be trying to connect to the default MySQL port 3306.

This guide explains how to fix both problems safely.

Why Does XAMPP MySQL Shut Down Unexpectedly?

XAMPP’s MySQL component uses MariaDB. A shutdown can happen for several reasons, including:

  • Another MySQL/MariaDB service is already using port 3306.
  • MySQL was not shut down correctly.
  • InnoDB is performing crash recovery.
  • Another application is using the same port.
  • MySQL/MariaDB has a configuration problem.
  • Windows stopped the database process.
  • Database files may have become damaged.

One of the first things to check is whether port 3306 is already being used.

Check Whether Port 3306 Is Already in Use

Open Command Prompt as Administrator and run:

netstat -ano | findstr :3306

If you see a result containing:

TCP    0.0.0.0:3306    0.0.0.0:0    LISTENING    1234

the last number is the process ID (PID).

You can identify the application using that PID with:

tasklist /FI "PID eq 1234"

Replace 1234 with the PID displayed on your computer.

If another MySQL or MariaDB process is using port 3306, you can either stop that service or configure XAMPP MariaDB to use another port.

Change XAMPP MySQL Port from 3306 to 3307

If port 3306 is occupied, open:

D:\xampp\mysql\bin\my.ini

Look for:

port=3306

Change it to:

port=3307

Depending on your configuration, you may find the port setting in more than one section. Make sure the relevant MariaDB/MySQL server configuration uses 3307.

Save the file.

Then restart XAMPP and start MySQL.

Check That MariaDB Is Listening on Port 3307

Open Command Prompt and run:

netstat -ano | findstr :3307

If MariaDB is running correctly, you should see a process listening on port 3307.

You can also test the connection directly:

D:\xampp\mysql\bin\mysql.exe -u root -P 3307

If your root account has a password, use the appropriate password option or enter the password when prompted.

Why Is phpMyAdmin Not Connecting After Changing the Port?

Changing the MySQL port does not automatically change every phpMyAdmin connection setting.

For example, your MariaDB server may now be running at:

127.0.0.1:3307

while phpMyAdmin is still trying:

127.0.0.1:3306

Therefore, phpMyAdmin cannot connect to the database.

Update phpMyAdmin Configuration

Open:

D:\xampp\phpMyAdmin\config.inc.php

Find the server configuration.

You may have something similar to:

$cfg['Servers'][$i]['host'] = 'localhost';

Set the host and port explicitly:

$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = '3307';

For example:

$i++;

$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = '3307';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';

If your existing configuration contains other settings, don’t replace the entire file. Modify only the relevant connection settings.

Restart XAMPP

After changing the configuration:

  1. Stop Apache.
  2. Stop MySQL.
  3. Start Apache.
  4. Start MySQL.
  5. Wait until both services are running.

Then open:

http://localhost/phpmyadmin/

Important

You normally do not need to use:

http://localhost:3307/phpmyadmin/

Port 3307 is the MariaDB/MySQL port.

phpMyAdmin is accessed through the web server, normally Apache, so the usual address remains:

http://localhost/phpmyadmin/

Check Apache Separately

If this URL does not open:

http://localhost/phpmyadmin/

check whether Apache is running.

Try:

http://localhost/

If http://localhost/ also doesn’t open, the problem may be with Apache rather than MySQL.

If the XAMPP dashboard opens but phpMyAdmin reports a database connection error, then check the MySQL/MariaDB port configuration.

Common Error After Changing the Port

You may see an error similar to:

mysqli::real_connect(): (HY000/2002):
No connection could be made because the target machine actively refused it.

This usually indicates that phpMyAdmin is attempting to connect to a port where MariaDB isn’t listening.

Check:

netstat -ano | findstr :3307

Then verify that phpMyAdmin uses:

$cfg['Servers'][$i]['port'] = '3307';

Check MySQL Error Logs

If MySQL continues to shut down, changing the port may not be the real solution.

Check the MariaDB error log inside:

D:\xampp\mysql\data\

Depending on the XAMPP installation, you may find a file such as:

mysql_error.log

or a .err file.

Look near the bottom of the log for messages containing:

[ERROR]
InnoDB
Can't bind
port
corrupt
shutdown
Access denied

These messages can identify the actual reason MariaDB stopped.

What Does “Starting Crash Recovery” Mean?

After an unexpected shutdown, MariaDB may display messages such as:

InnoDB: Starting crash recovery from checkpoint

This means InnoDB is recovering transactions from its redo logs after an earlier unclean shutdown.

For example:

InnoDB: Starting final batch to recover pages from redo log.

Crash recovery by itself does not mean that the database is permanently corrupted.

If MariaDB subsequently reports:

InnoDB: 10.4.32 started

it indicates that the InnoDB engine successfully initialized at that point.

Repeated unexpected shutdowns should still be investigated.

Don’t Immediately Delete InnoDB Files

A common internet recommendation is to delete files such as:

ibdata1
ib_logfile0
ib_logfile1

or replace the entire XAMPP data directory with the backup directory.

This can cause database or table loss.

Before attempting database repair:

  1. Stop XAMPP.
  2. Make a complete backup of:
D:\xampp\mysql\data\
  1. Preserve your database files.
  2. Check the MariaDB error log.
  3. Determine whether the problem is a port conflict, configuration issue, service conflict, or actual database corruption.

Quick Troubleshooting Checklist

If XAMPP MySQL shuts down unexpectedly, use this sequence:

Step 1: Check port 3306

netstat -ano | findstr :3306

Step 2: Identify the process

tasklist /FI "PID eq YOUR_PID"

Step 3: Change the MariaDB port if necessary

In:

D:\xampp\mysql\bin\my.ini

use:

port=3307

Step 4: Verify port 3307

netstat -ano | findstr :3307

Step 5: Update phpMyAdmin

In:

D:\xampp\phpMyAdmin\config.inc.php

use:

$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = '3307';

Step 6: Restart XAMPP

Restart Apache and MySQL.

Step 7: Open phpMyAdmin

Go to:

http://localhost/phpmyadmin/

Step 8: If MySQL still shuts down

Check:

D:\xampp\mysql\data\

for the MariaDB/MySQL error log and inspect the latest error messages.

Conclusion

Changing the XAMPP MariaDB port from 3306 to 3307 can resolve a port conflict, but phpMyAdmin must also be configured to use the new database port.

The key configuration is:

$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = '3307';

After that, continue accessing phpMyAdmin through:

http://localhost/phpmyadmin/

If MariaDB continues to shut down even after changing the port, don’t immediately delete database files. Check the MariaDB error log first and make a backup of the data directory before attempting any database repair.