I need some assistance changing the port that MySQL is running on.

So, according to http://dev.mysql.com/doc/refman/5.1/en/option-files.html

MySQL first looks for conf in WINDIR\my.ini, WINDIR\my.cnf ....etc.......

None of these files exist, not even my.ini in the install dir.

Therefore I created my.ini in the install dir... @C:\Program Files\MySQL\MySQL Server 5.5\my.ini

The contents of the file is:


I have tried various things with this ini, I used the examples, but when ever I go to services.msc and restart the MySQL55 service after having saved the updated ini, it always freakin starts on the default port 3306

  • 1
    Did you check the command line on the service to make sure that (or where) the .ini file is specified? Sep 27 '11 at 15:30
  • -2 ?? :-( .... @CG: TBH I am not sure how to check it via the console, can you tell me what command to use? thanks
    – Chris
    Sep 27 '11 at 15:35
  • 1
    I edited your question and removed the unnecessary ranting in hopes that you wouldn't get anymore downvotes.
    – GregD
    Sep 27 '11 at 15:36
  • all I did was say ARRRG lol - love it SE, thanks anyway Greg :)
    – Chris
    Sep 27 '11 at 15:37
  • 1
    @Chris Double click the services in the services.msc console, and look at the "Path to executable", it usually has some parameters after the .exe. Sep 27 '11 at 15:37

Looking at the command line in the services console (services.msc) will tell you specifically where the proper .ini file is, and then you can modify that file (and hopefully get the results you want).

The command line specified for the service is shown in the Service's properties dialog. To find it:

  1. Right-click on the service name
  2. Click properties

Read the "Path to executable:" value. This is the command line used for the service. MySql will specify the --defaults-file option which has a path to the my.ini file.

  • How would you acquire the command line in a normal windows? I've browes through sc command's options, no clue. Feb 23 '16 at 13:35

Just head over to your C:\Program Files\MySQL\MySQL Server 5.5\ and you will find various .ini files there eg. my-huge.ini, my-small.ini, my-template.ini, my-large.ini (and most probably my.ini too).

By default MySQL Server 5.5 will look for C:\Program Files\MySQL\MySQL Server 5.5\my.ini (unless another file is defined on the service command line using the --defaults-file= option)

So I'm guessing that your problem is not that the MySQL service is not parsing the correct .ini file (since you created it in the correct path and with the correct name) rather than the content in the file itself. Just a my.ini file with the content you're mentioning on your question is not enough.

Find my-small.ini in the folder above, rename it to my.ini, then open the file with notepad and edit the line

port = 3306


port = 44999

Restart the mysql service from within the Windows Service Manager (right click on My Computer -> Manage -> Services and Applications -> Services) and your MySQL server should now be listening on port 44999 (remember you'll have to open this port on the Windows Firewall too!)


Did you install it in the default manner with default settings?

Randomly sticking an ini file in there won't do any good if the application isn't set to read that location for settings...

At this point I'd get the sysinternals procmon tool (free) and have it watch as you reload the server application, then look and see what file location(s) it is looking in for its configuration. Might find the actual config file somewhere on your system too using that tool, then change the settings there.


In MySQL 5.6, the configuration file, my.ini, is located in a hidden folder named C:/ProgramData. You can open the MySQL Command-line utility, and type in "status" to see the port in use.

  • It appears that for MySQL 5.7, it only reads configuration from that file. At least, it's the behavior to change the lower_case_table_names configuration. Apr 11 '17 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.