change MySQL port

Problems with the Windows version of XAMPP, questions, comments, and anything related.

change MySQL port

Postby matteosistisette » 11. January 2012 12:24

Hi,

What's the best and quickest way to change xampp settings so that the MySQL server will use a given port other than 3306 and EVERYTHING else in xampp will work? That is, I have to change the configuration for the server, the client, and php (and I don't know if something specific has to be done for phpmyadmin, I guess not).

Also I'd like to do so on a pendrive installation in such a way that when I move the pendrive to another computer and start xampp, these changes (the ones made in order to use a different port for mysql) are not automatically overwritten when setting up. (i guess this won't happen, but just have to be sure).

I guess this should take just editing a couple or three config files; however I did a quick grep for "3306" and found a LOT of occurrences, though they seem to be mainly in comments.

I need all this because I'm going to use xampp on places where port 3306 is already taken (by another mysql server, I guess). By the way I can't believe this is not a FAQ...

Thanks in advance,
m.
matteosistisette
 
Posts: 38
Joined: 11. January 2011 12:22
Operating System: Windows 7 64bit; Ubuntu 11.10

Re: change MySQL port

Postby Sharley » 11. January 2012 12:34

Would you be so kind as to add your XAMPP version and Operating System to your profile as per these instructions and related info:
viewtopic.php?f=16&t=48626
Thanks. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: change MySQL port

Postby matteosistisette » 11. January 2012 12:58

Done.
Obviously I'm asking about Windows since this is the "apache for windows" forum; in my profile I've entered both Windows 7 64bit and Ubuntu 11.10 because I use xampp on both.
matteosistisette
 
Posts: 38
Joined: 11. January 2011 12:22
Operating System: Windows 7 64bit; Ubuntu 11.10

Re: change MySQL port

Postby Sharley » 11. January 2012 12:59

Thanks for that. 8)

You can change the port in \xampp\mysql\bin\my.ini file in a couple of places.

There is also a couple of default MySQL port settings in the \xampp\php\php.ini file that would also need changing.

Save the files and restart Apache and MySQL to test.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: change MySQL port

Postby matteosistisette » 11. January 2012 13:07

I'm having a "recursive" look at the installation script and it looks almost like it is supposed to automatically detect if the standard ports are blocked: is it so? If they are, does it automatically switch to some other port? By looking at a file called checkports.bat it looks like it is supposed to record information about free/blocked ports into a file called checkports.ini; however there's no such file (and I did run the install script).... is it deleted after setup? or is it that checkports.bat is not called at setup??

I did a test on my windows (virtual) machine while having another program listening on port 3306 and xampp indeed seems to work, including mysql, and phpmyadmin works, but this was just a quick test, this is not my target environment. Can I expect xampp to work out of the box on a computer where there is actually another mysql (or maybe mssql) server using port 3306, and not interfere with it? Also I only tried phpmyadmin, I haven't tried a custom php script connecting to mysql. Does phpmyadmin take some extra care when connecting to mysql server, or can I expect that if phpmyadmin works, any other php communicating with mysql will work?

thanks
m.
matteosistisette
 
Posts: 38
Joined: 11. January 2011 12:22
Operating System: Windows 7 64bit; Ubuntu 11.10

Re: change MySQL port

Postby Sharley » 11. January 2012 13:12

In the new version control panel found in the xampp folder:
xampp-control-3-beta.exe
you will find a Netstat button that will check the ports for you.

The latest version of the XCPv3 can be downloaded from the link in my signature.
It has more features and a better log reporting window.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: change MySQL port

Postby matteosistisette » 11. January 2012 13:18

Well no, that auto-port-switching fantasy of mine definitely is not true. I see in phpinfo() that it is using 3306 and all the ini file you mentioned say 3306.

What I can't understand then is how it is possible that phpmyadmin works fine while I have another program listening to port 3306 (and actually receiving data from it from another program) !!!!!!
matteosistisette
 
Posts: 38
Joined: 11. January 2011 12:22
Operating System: Windows 7 64bit; Ubuntu 11.10

Re: change MySQL port

Postby matteosistisette » 11. January 2012 13:30

Sharley wrote:In the new version control panel found in the xampp folder:
xampp-control-3-beta.exe
you will find a Netstat button that will check the ports for you.


Thanks. Yes, the 3-beta control panel does say there is a problem with port 3306 being in use by another program; yet, phpmyadmin works!
In the netstats, both my other program _and_ mysqld.exe are using port 3306!!!! How can that be? Isn't it impossible to have two processes bound to the same TCP port?!?!?!
matteosistisette
 
Posts: 38
Joined: 11. January 2011 12:22
Operating System: Windows 7 64bit; Ubuntu 11.10

Re: change MySQL port

Postby Sharley » 11. January 2012 13:41

In the latest XCPv3 you will find a 'Config' button then when clicked on you will find another button 'Service and Port Settings' where you can change the number of port 3306 so that the control panel will check that new port instead of port 3306.

Make sure that you have changed the port numbers in the above mention ini files.

I have no idea why the Netstat is showing a shared port 3306 if the MySQL in XAMPP is now using another port.

Perhaps you have ticked the Windows Service module for Apache and MySQL and a registry entry for the service is the culprit.

Best not to use the Windows service for MySQL and Apache until you are satisfied with the port changes - removing the tick by clicking on it will uninstall the Windows services.

phpMyAdmin relies on the MySQL ini settings with regard to what port is in use by MySQL in XAMPP.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: change MySQL port

Postby matteosistisette » 11. January 2012 15:37

Sharley wrote:I have no idea why the Netstat is showing a shared port 3306 if the MySQL in XAMPP is now using another port.


I haven't done anything to have MySQL use another port and everything looks like it is actually using 3306. The my.ini says 3306 and so does php.ini (I never touched them).

It seems both program actually _are_ sharing port 3306 (something that should be impossible. Maybe Windows allows it? It allows a lot of wrong things...). Indeed my other program is just listening to the port as a server, but no data is being transferred. I have also tried connecting to it a client (the protocol doesn't have anything to do with mysql, of course) but I haven't try to do this _and_ using mysql _at the same time_. May be that would be when things would get screwed up (the data of the two communications getting mixed).

And no i didn't install the services. The checkboxes are shown with a grey tick on it - indeed if I had to tell by looking at them I would say they are ticked, but if I click them I am asked whether to _install_ (not uninstall) the service. I guess the grey tick means "unchecked" and becomes a green tick when checked (very bad UI design in my opinion).


Anyway, in order to use another port I will simply edit my.ini and php.ini. I just thought there would be an easier and less error-prone way, since it seemed to me a pretty common need. And this strange works-out-of-the-box-though-other-program-is-using-the-port thing (plus the existence of the checkports script plus the lack of a simple way to change port or a faq about it) made me suspect xampp may be automatically and transparently switching to another port, but apparently that's not the case.
matteosistisette
 
Posts: 38
Joined: 11. January 2011 12:22
Operating System: Windows 7 64bit; Ubuntu 11.10


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 151 guests