How to Fix XAMPP Port Issues on MySQL Server (Localhost)using my.ini and config.inc.php configuration

If you’re working with XAMPP, you may have encountered an issue where the default ports (3306 for MySQL) are already in use. This can cause XAMPP to fail to start, leaving you unable to develop or test your web applications. Fortunately, there is a solution to this problem: configuring your my.ini file in the XAMPP installation folder. In this blog post, we’ll show you how to fix XAMPP port issues using my.ini configuration and config.inc.php.

Step 1: Locate the my.ini File The my.ini file is the MySQL configuration file that XAMPP uses to set up the MySQL server. To locate the file, open the XAMPP control panel and click on the “Config” button next to MySQL. Then select “my.ini” from the dropdown menu.

Click Config
Click my.ini

Step 2: Edit the my.ini File Once you’ve located the my.ini file, open it with a text editor and add the following lines to the end of the file:

port= 3307

[mysqld] port=3307

Changing Port into 3307

This will set the MySQL port to 3307, which is an alternative port that XAMPP uses by default. You can also choose any other available port number if you prefer.

Step 3: Save the Changes After adding the port configuration to the my.ini file, save the changes and close the file.

Step 4: Update the XAMPP Configuration File Next, you need to update the XAMPP configuration file to use the new MySQL port. To do this, open the config.inc.php file located in the XAMPP installation folder (usually C:\xampp\phpMyAdmin\config.inc.php) and find the following line:

$cfg[‘Servers’][$i][‘host’] = ‘127.0.0.1’;

Replace the quotes by adding new port number you set in the my.ini file, like this:

$cfg[‘Servers’][$i][‘host’] = ‘127.0.0.1:3307’;

Save the changes to the config.inc.php file and close it.

Step 5: Restart XAMPP in order to implement the modifications you made to the config.inc.php and my.ini files. Now, MySQL ought to launch without encountering any port problems.

In conclusion, utilizing the my.ini setting in config.inc.php to fix XAMPP port difficulties is a quick and easy workaround that can help you avoid a lot of hassle. You should be able to fix any port issues by following the instructions provided in this blog article, and you can then quickly resume creating and testing your web apps.

Leave a Comment

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