Good question — this is a common problem when running XAMPP on a PC where MySQL (community server or Workbench install) is already installed.

👉 Both XAMPP’s MySQL (called MariaDB usually) and your standalone MySQL server will try to use port 3306, which leads to a port conflict.

📌 Two Solutions

1️⃣ Change XAMPP MySQL (MariaDB) Port

👉 Easiest way if you want to run both servers at the same time.

Steps:

  1. Open XAMPP Control Panel.
  2. Click Config button next to MySQL > open my.ini.
  3. Find:
    [mysqld] port=3306
  4. Change to another port, e.g. 3307:
    port=3307
  5. Save and close my.ini.
  6. Start MySQL from XAMPP.

👉 Now XAMPP MySQL runs on port 3307, standalone MySQL still on 3306.

Access XAMPP MySQL:

  • PHP code:
    mysqli_connect(‘localhost’, ‘root’, ”, ‘dbname’, 3307);
  • phpMyAdmin:
    Edit xampp/phpMyAdmin/config.inc.php
    $cfg[‘Servers’][$i][‘port’] = ‘3307’;

2️⃣ Stop Standalone MySQL When Using XAMPP

If you do not need both servers running together:

  1. Go to Windows Services (press Win+R → type services.msc).
  2. Find MySQL service (maybe called MySQL80 or similar).
  3. Right click → Stop.
  4. Start MySQL from XAMPP (default port 3306 now free).

👉 Drawback: you need to stop/start services each time.


⚠️ Important Notes:

  • XAMPP ships with MariaDB, fully compatible with MySQL.
  • If you only want one MySQL instance, you can choose to disable or uninstall the other.
  • Running both is perfectly fine, just use different ports.
One thought on “How can I run mysql in XAMPP server when I already have MySQL server installed in the same pc?”
  1. Please watch this video:
    [videopress 5PotyKqK]

    When you have both XAMPP and a standalone MySQL server installed on the same computer, you may run into conflicts as both servers use the same default ports. To run MySQL in XAMPP, you will need to modify the default port number used by either the standalone MySQL server or the XAMPP MySQL server. Here are the steps you can follow:

    1. Stop the standalone MySQL server: Before starting the MySQL server in XAMPP, you need to stop the standalone MySQL server to avoid conflicts.
    2. Change the MySQL port in XAMPP: Open the XAMPP control panel and click on the “Config” button next to the Apache service. In the Apache configuration file, locate the line “Listen 3306” and change the port number to a different one, such as 3307. This will allow the XAMPP MySQL server to run on a different port.
    3. Start the XAMPP MySQL server: Once the port has been changed, you can start the XAMPP MySQL server from the XAMPP control panel.
    4. Connect to the XAMPP MySQL server: To connect to the XAMPP MySQL server, you will need to specify the new port number in your connection parameters. For example, if you changed the port to 3307, you would use “localhost:3307” as the server name when connecting to the MySQL server in XAMPP.

    These steps should allow you to run the MySQL server in XAMPP while avoiding conflicts with a standalone MySQL server.

Leave a Reply

Your email address will not be published. Required fields are marked *