7

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:

port=44999

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

Sam Cogan
  • 38,736
  • 6
  • 78
  • 114
Chris
  • 299
  • 2
  • 4
  • 9
  • 1
    Did you check the command line on the service to make sure that (or where) the .ini file is specified? – Coding Gorilla 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. – Coding Gorilla Sep 27 '11 at 15:37
  • Nice one Gorilla! I will try edit this ini instead:: "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --defaults-file="C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.5\my.ini" MySQL55 – Chris Sep 27 '11 at 15:40
  • @Chris I added it as an answer so you can mark it. =) – Coding Gorilla Sep 27 '11 at 15:42
  • @Chris Well I can't protect you from yourself. If you're going to edit your own posts and add back in things like "Thanks for the troll votes... what a friendly community..." expect to get thrashed. This is a free community and a lot of us spend a lot of time donating to help make this a good place to go to get your questions answered with regard to System Administration. – GregD Sep 27 '11 at 15:44

4 Answers4

13

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.

Dusty Vargas
  • 296
  • 1
  • 3
  • 12
Coding Gorilla
  • 1,938
  • 12
  • 10
  • How would you acquire the command line in a normal windows? I've browes through sc command's options, no clue. – Makan Feb 23 '16 at 13:35
3

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

[mysqld]
port = 3306

to

[mysqld]
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!)

George Tasioulis
  • 2,019
  • 2
  • 17
  • 17
2

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.

Bart Silverstrim
  • 31,172
  • 9
  • 67
  • 87
2

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.

axiom82
  • 121
  • 2
  • 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. – Sylvain Filteau Apr 11 '17 at 15:56