60

What is the location of mysql client .my.cnf using XAMPP in Windows?

Clarification: This file does not exist by default, so when you create it, where should you place it, in order for the command line client to read it automatically?

dawsnap
  • 994
  • 9
  • 21
Alex R
  • 11,364
  • 15
  • 100
  • 180

15 Answers15

61

Type this:

mysql --help 

Then look at the output. There is a block of text about 3/4 the way down describing what files it finds its defaults .my.cnf from. Here is an example from XAMPP v3.2.1, default options are read from the following files in the given order:

C:\Windows\my.ini 
C:\Windows\my.cnf 
C:\my.ini 
C:\my.cnf 
C:\xampp\mysql\my.ini 
C:\xampp\mysql\my.cnf 
C:\xampp\mysql\bin\my.ini 
C:\xampp\mysql\bin\my.cnf

Your setup may differ. You will have to run the command to check the actual paths on your particular system.

SaschaM78
  • 4,376
  • 4
  • 33
  • 42
Billy
  • 1,212
  • 10
  • 10
  • 2
    Wrong. Sudantha's answer is correct :) XAMPP keeps it's files solely in the X:\xampp folder (or any installation folder). – Eduard Luca May 09 '13 at 22:54
  • 2
    How is it wrong? My statement was that the command 'mysql --help' will tell you where to find the file. Even if it doesn't report the same as my example above it should still work the same way. Have you found that it doesn't? – Billy May 14 '13 at 21:58
  • 1
    No, sorry, that part is probably correct, I meant the example you gave is wrong in this case. – Eduard Luca May 15 '13 at 22:58
  • 1
    Wrong in my case: For whatever reason the file is in none of the positions printed out here (the print is likely the same on my machine). – Matthias Ronge Mar 06 '14 at 09:16
  • 7
    The whole point is if you type that command it will list where the config is searched for in whatever build of mysql you are using. If your config isn't in one of the places in my example then either you have no config or the search path is different. – Billy Mar 06 '14 at 18:16
  • @Billy, When it says "in the given order", is that an ascending order or a descending order? Does the options in the last entry override the previous entries or vice-versa? – Pacerier Oct 18 '14 at 21:26
  • 1
    The first in the list is the first that it checks. Once it finds one it stops looking. – Billy Oct 20 '14 at 18:23
  • This is the only correct answer. Most other answers are talking about the server "ini" file which is not what my question is about at all. – Alex R Mar 13 '15 at 11:49
34

Look in the MySQL config file C:\xampp\mysql\bin\my.ini.

At the top of that file are some comments:

# You can copy this file to
# C:/xampp/mysql/bin/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is C:/xampp/mysql/data) or
# ~/.my.cnf to set user-specific options.

There it tells you where to find your .my.cnf file.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Sudantha
  • 15,684
  • 43
  • 105
  • 161
24

After checking the default locations on Win7 with mysql --help and unable to find any config file, I manually searched for my.ini and found it at C:\ProgramData\MySQL\MySQL Server x.y (yep, ProgramData, not Program Files).

Though I used an own my.ini at Program Files, the other configuration overwrote my settings.

Hein van Dyke
  • 468
  • 6
  • 10
13

Go to control panel → services, look for MySQL and right click choose properties. If there, in “path to EXE file”, there is a parameter like

--defaults-file="X:\path\to\my.ini"

this is the file the server actually uses (independent of what mysql --help prints).

Matthias Ronge
  • 9,403
  • 7
  • 47
  • 63
7

Using the XAMPP control panel, click on the Config button for MySQL and you'll find the file it's currently using.

Alex R
  • 11,364
  • 15
  • 100
  • 180
Moustafa Elqabbany
  • 1,110
  • 9
  • 10
5

XAMPP uses a file called mysql_start.bat to start MySQL and if you open that file with a text editor you can see what config file is trying to use, in the current version it is:

mysql\bin\mysqld --defaults-file=mysql\bin\my.ini --standalone --console

If you installed XAMPP on the default path it means it is on c:/xampp/mysql/bin/my.ini


If somehow the file doesn't exist you should open a console terminal (start-> type "cmd", press enter) and then write "mysql --help" and it prints a text mentioning the default locations, in the current version of XAMPP is:

C:\Windows\my.ini C:\Windows\my.cnf C:\my.ini C:\my.cnf C:\xampp\mysql\my.ini C:\xampp\mysql\my.cnf
Ivan Castellanos
  • 8,041
  • 1
  • 47
  • 42
4

It's usually in your MySQL installation folder like in C:\Program Files\MySQL\MySQL Server 5.5\my.ini or C:\xampp\mysql\bin

If it's not there, it's highly possible that you have none, and that MySQL is just loading default values.

You might have to enable hidden Files and Folders to see it. Go to Folder Options: in any folder, go to the top horizontal main text menu >> Tools >> Folder Options. Enable 'View Hidden Files and Folders', and 'View Protected System Files', save & exit

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
ESG
  • 8,988
  • 3
  • 35
  • 52
1

If you connect to the server with MySQL Workbench add look at 'Management' and 'Options File' in the menu on the left, then the location of the config file being used by that server is shown at the bottom of the pane on the right.

Glen
  • 11
  • 1
0

Create it yourself in folder c:\xampp\mysql.

dns_nx
  • 3,651
  • 4
  • 37
  • 66
Ebrahim Asadi
  • 285
  • 3
  • 13
0

On Windows you can open a command window and type the command

sc qc mysql

Or:

sc qc mariadb

which (depending on your flavor and version) will output something like:

[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: mariadb
        TYPE               : 10  WIN32_OWN_PROCESS 
        START_TYPE         : 2   AUTO_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : "C:\Program Files\MariaDB 10.4\bin\mysqld.exe" "--defaults-file=C:\Program Files\MariaDB 10.4\data\my.ini" "MariaDB"
        LOAD_ORDER_GROUP   : 
        TAG                : 0
        DISPLAY_NAME       : MariaDB
        DEPENDENCIES       : 
        SERVICE_START_NAME : NT AUTHORITY\NetworkService

From this you can see the location of the my.ini file.

You can also change it with the same "sc" command like this:

sc config mysql binPath= <binary path>

Or:

sc config mariadb binPath= <binary path>

For example:

sc config mariadb binpath= "\"C:\Program Files\MariaDB 10.4\bin\mysqld.exe\" \"--defaults-file=M:\data\my.ini\" \"MariaDB\""
bikeman868
  • 2,236
  • 23
  • 30
-1

Apologize for resurrect this thread, but for Windows 8.x users can find my.cnf at this folder:

C:\ProgramData\MySQL\MySQL Server 5.6\my.ini

Then also can find data folder on same folder.

Carlos Spohr
  • 507
  • 11
  • 24
-1

If you're on Cygwin this command will show you the locations:

mysql --help |grep -A1 Default|grep my
the
  • 21,007
  • 11
  • 68
  • 101
-1

You can find it in C:\ProgramData\MySQL\MySQL Server 5.7

Devaniyas
  • 9
  • 5
-1

I don't have XAMPP installed, but the question I did end up at when I couldn't find the my.cnf or my.ini (I can not find my.cnf on my windows computer) was closed, and led here.

So - If you've installed MariaDB on Windows, and followed Windows best practices to load data somewhere OTHER than \program files - in my case on a "d:" drive, then your my.ini will be located where you put your "data" directory.

J. Gwinner
  • 931
  • 10
  • 15
  • I don't get the downvote. Yes, I don't have XAMPP installed, but an Internet search for the location of my.cnf leads here, and I believe that if XAMPP was installed on a location other than C:, you would end up at the same problem. If you note that the error message that WAS appropriate points here. So a more general problem -> a less general problem, and I get downvoted because I'm answering the more general problem, with a solution that also fixes the less general problem. wut – J. Gwinner Jul 02 '21 at 21:30
-2

If you install it directly with the community installer on windows 2008 server, it will reside on c:\ProgamData\MySql\MysqlServerVersion\my.ini

joss
  • 1