XAMPP – MySQL Service detected with wrong path – running multiple MySQL on same computer

| |

XAMPP comes with Apache as the Web Server and MySQL database server. Apache uses HTTP port 80 and MySQL uses port 3306. If you already have other web server such as IIS on the same computer, then port 80 will not be available to XAMPP Apache as it is already taken by IIS server. Also, if you have MySQL server already installed on the computer and if you install XAMPP, then port 3306 will not be available to XAMPP MySQL as it is already taken by MySQL earlier. In such as scenario, if you start XAMPP control panel, you will see the following error.

12:35:23 [mysql] MySQL Service detected with wrong path
12:35:23 [mysql] Change XAMPP MySQL settings or
12:35:23 [mysql] Uninstall/disable the other service manually first
12:35:23 [mysql] Found Path: "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --defaults-file="C:\Program Files\MySQL\MySQL Server 5.5\my.ini" MySQL
12:35:23 [mysql] Expected Path: c:\xampp\mysql\bin\mysqld.exe --defaults-file=c:\xampp\mysql\bin\my.ini mysql
12:35:23 [mysql] Problem detected!
12:35:23 [mysql] Port 3306 in use by "mysqld.exe"!
12:35:23 [mysql] MySQL WILL NOT start without the configured ports free!
12:35:23 [mysql] You need to uninstall/disable/reconfigure the blocking application 12:35:23 [mysql] or reconfigure MySQL to listen on a different port

The problem occurs because the ports expected the XAMPP’s Apache and MySQL are not available. If you do not need the other web server (Eg. IIS) and the MySQL Server, then you can uninstall them. But if you need to keep them both, we need to arrange other ports for XAMPP Apache and XAMPP MySQL to use. In this post, we will see how to configure XAMPP so that Apache and MySQL work on the same computer with multiple MySQL services.

1) Confirm that HTTP port 80 and MySQL port 3306 is already taken

Firstly, confirm that port 80 is already taken by another web server.

  • Open a web browser and type ‘localhost’
  • You should get the web server’s page. If the web server is an IIS server, you will get the default IIS Page if the web server is running. That means port ’80’ is already taken.

Solution: change the HTTP port for XAMPP Apache from 80 to 8080 (for example).

Secondly, confirm that port 3306 is already taken by MySQL service.

  • Click Start > Type ‘Services.msc’ > click to open
  • Sort by Name and find MySQL in the list of services.
  • You should be able to find a service already running by the name ‘MySQL’, which means MySQL service is already running and that port 3306 is already taken.

Solution: We need to assign another port number for XAMPP MySQL

2) Change HTTP port 80 to 8080 and MySQL port 3306 is already taken

a) Open XAMPP Control Panel ‘as Administrator’ / with elevated permission.

b) Click ‘Config’ button available near top right corner of XAMPP Control Panel > next, click “Service and Port Settings”

c) Click APACHE tab > change the number in the ‘MAIN PORT’ field to ‘8080

d) Click SAVE

e) Click on MySQL tab > change service name to something like ‘mysqlxampp‘ and MAIN PORT number to ‘3307

f) Click SAVE > SAVE

xampp-service-settings

We are now back to XAMPP Control Panel.

g) Change Apache port from ’80’ to ‘8080’ in the httpd.conf configuration file

  • On XAMPP Control Panel > Click on ‘APACHE’ –  ‘CONFIG’ button > Click on ‘Apache (httpd.conf)
    (Full path to the file is: “C:\xampp\apache\conf\httpd.conf”)
  • The Apache httpd.conf file will open in a Notepad
  • Do ‘Control Find’ and find the line ‘Listen 80’
  • Change ‘Listen 80’ to ‘Listen 8080’
  • Save the file

Note: If you started XAMPP Control Panel ‘as Administrator’, you should be able to save the file.

h) Change XAMPP MySQL port from the default 3306 to 3307

  • On XAMPP Control Panel > Click on ‘MySQL’ –  ‘CONFIG’ button > Click on ‘my.ini’
    (The full path to the file is: “C:\xampp\mysql\bin\my.ini”)
  • The my.ini will open in a Notepad. Find the port 3306 in two places and change it to 3307.
  • Find the line ‘port=3306‘ which is under [client] and change it to ‘port=3307’
  • Find ‘port=3306‘ again, and under [mysqld], change it to ‘port=3307’
  • Save the file.
  • After the above changes, it looks like:

[client]
# password = your_password
port=3307
socket=”C:/xampp/mysql/mysql.sock”
# Here follows entries for some specific programs
# The MySQL server
default-character-set=utf8mb4

[mysqld]
port=3307

  • On XAMPP Control Panel > Click on ‘APACHE’ –  ‘CONFIG’ button > Click on ‘php.ini’
  • Find ‘3306’ and change it to ‘3307’ at the line: mysqli.default_port=3307
  • Find ‘3306’ again and change it to ‘3307’ at the line: mysql.default_port=3307
  • Save the file

We have changed the HTTP port of Apache from 80 to 8080 and MySQL port for XAMPP from 3306 to 3307.

  • Now QUIT XAMPP Control Panel.
  • Start XAMPP Control Panel  as administrator.

The error mentioned above should not show now.

  • Click START next to APACHE and click START next to MySQL.

The APACHE and MySQL services should now run successfully with the newly assigned ports.

  • Click on the ADMIN button next to APACHE and you should be able to view the default XAMPP Apache page, whose address is ‘http://localhost:8080/dashboard/ (Note the port number 8080).
  • Click on the ADMIN button next to MySQL and you should be able to view the default XAMPP phpMyAdmin page, whose address is ‘http://localhost:8080/phpmyadmin

So, we have successfully changed the port number from 80 to 8080 for XAMPP Apache and port 3306 to 3307 for XAMPP MySQL.

It may be noted that by following the above steps, the port for MySQL has been changed from the defaul’3306′  to ‘3307’. Therefore, when we install applications in XAMPP, ensure that you provide MySQL post ‘3307’.

For example, after the MySQL port change, if we install Drupal CMS, we will get the following error since the MySQL connection port is the default port 3306.

ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it

At the DB information page, provide the DB Name, DB Username, DB Password, then, click on the ‘Advanced Options. From here you can change the default MySQL database port from 3306 to 3307. After which the installation can proceed without the above error.

The MySQL service for XAMPP Control Panel is not found in list of services in Services.msc

  • Create the service entry
  • Open Windows command and type the following line

sc.exe create “mysqlxampp” binPath= “C:\xampp\mysql\bin\mysqld.exe –defaults-file=c:\xampp\mysql\bin\my.ini mysqlxampp”

windows-command-create-service

Note: In this example, the service entry name ‘mysqlxampp‘ is kept the same as the MySQL service name entered in step (e) above, which is set in the XAMPP > Service Settings.

  • Open Services.msc, and you should be able to find the MySQL service by the name ‘mysqlxampp,
  • Right Click on ‘mysqlxampp‘ > Properties and set Startup Type: Automatic and Start the service
  • When you START and STOP the MySQL Service from the XAMPP Control Panel, the service ‘mysqlxampp‘ would also show ‘Running’ or ‘Stopped’ in the Services.msc window. If you don’t see changes immediately, just click the REFRESH button in the Services window.

services-mysql

So, in this way, you can run multiple MySQL services on the same computer so that you can run XAMPP MySQL for development activities and also keep running MySQL Server for other applications.

Previous

How to enable PHP OPCache in localhost running XAMPP on Windows?

How To Uninstall Intune Company Portal Android App?

Next

Leave a Reply