Where is the configuration file? - mysql

I have just installed MySQL on my Windows XP machine.
Now, because of the nature of my task I need to make some changes to the my.ini file.
However all I can see in the C:\Program Files\MySQL\MySQL Server 5.6 is the file my-default.ini.
What should I do?
My intent is to rename this file to my.ini and make the changes or copy and rename it to some other place?

Just create a copy of the default, name it my.ini and then restart MySQL.
Per the documentation:
The new MySQL Configuration Wizard places the my.ini file in the
installation directory of the MySQL server. This helps associate
configuration files with particular server instances.
To ensure that the MySQL server knows where to look for the my.ini
file, an argument similar to this is passed to the MySQL server as
part of the service installation:
--defaults-file="C:\Program Files\MySQL\MySQL Server 4.1\my.ini"
Here, C:\Program Files\MySQL\MySQL Server 4.1 is replaced with the
installation path to the MySQL Server. The --defaults-file option
instructs the MySQL server to read the specified file for
configuration options when it starts.

Related

On Windows 10 MySQL service will not start unless --defaults-file is specified

Windows 10
MySQL 80
Default Installation
I have a my.ini file installed by default at [C:\ProgramData\MySQL\MySQL Server 8.0\my.ini]
My plan is to create a separate my.ini file at [C:\Program Files\MySQL\MySQL Server 8.0\my.ini]. So that I can add a couple of settings. My expectation is that the default my.ini will be loaded, and then this separate file will be loaded overriding any values which are specified in both files.
MySQL reports that:
"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:\Program Files\MySQL\MySQL Server 8.0\my.ini C:\Program Files\MySQL\MySQL Server 8.0\my.cnf"
Since I have the MYSQL80 service installed as a windows service, the service is defined with the --defaults-file option for the original default my.ini file. Reading the docs it says that when this option is used, only that file will be loaded.
If I remove this option from the Windows Service, then the service fails to start.
There are no errors in the .err file, or in the Windows Event Viewer.
Is the --defaults-file option required?
Is it possible to have the default my.ini file, and then have a separate user defined my.ini which will override any duplicate settings?
Thank you for your time.

My SQL installed in `Program Files` and can't see the `my.ini` files

In my machine (Windows 10) two MySQl versions are needed. The Project "A" is running in XAMPP. When I've started my second project, I've stopped the first SQL services and installed MySQL 5.7. In that I need to set lower_case_table_names = 2 for the case sensitive method.
I google it, they say:
open your MySQL configuration file: [drive]\xampp\mysql\bin\my.ini
look up for: # The MySQL server [mysqld]
add this right below it: lower_case_table_names = 2
save the file and restart MySQL service
I know that it's for XAMPP only.
But I've installed MySQL in Program Files. Here I couldn't able to see C:\Program Files\MySQL\MySQL Server 5.7\bin\my.ini files. Then where should I set the lower_case_table_names = 2 value?
Thanks in advance.
In XAMPP use the "Control Panel" to find the mysql.ini config file.
In a regular Windows install of MySQL the .ini file sits in C:\ProgramData\MySQL\MySQL Server.

Is the file "my.ini" in the wrong place?

In the WorkBench when I click on the Options File it says it can't find "C:\Program Files\MySQL\MySQL Server 5.0\my.ini"
I don't even have version 5.0 on the machine, I've only installed versions 5.6 and 5.7 of the server.
However there is a my.ini in "C:\ProgramData\MySQL\MySQL Server 5.5\my.ini".
If I just copy over the file I'm assuming that having two my.ini files will be confusing for the server. Or will they? And why is the WorkBench looking in the wrong place for this file?
Could this be why all login's except root have suddenly started to fail?
Have a look at the Connection settings. Right click on the connection adn select Edit Connections so you end up in Manage connections.
There is a tab called System Profile. Make sure that the path for Configuration file here is to the correct ini file. In your case the path should most likley be C:\ProgramData\MySQL\MySQL Server 5.5\my.ini

MySQL my.ini location

I have already seen
http://dev.mysql.com/doc/refman/4.1/en/mysql-config-wizard-file-location.html
how to know mysql my.cnf location
and
http://dev.mysql.com/doc/refman/5.1/en/option-files.html
But I am still stuck with the ages old question!
"Where is my my.ini"
I am using windows server 2008 with mysql 5.5.28. I installed the service using mysqld --install and I am able to use the mysql server using sqlyog. But unfortunately I am not able to find my.ini in installation directory or not in c:\ neither in c:\windows nor in data_dir query show variables like "mysql_home" returned nothing as well.
Any suggestions?
my.ini LOCATION ON WINDOWS MYSQL 5.6 MSI (USING THE INSTALL WIZARD)
Open a Windows command shell and type: echo %PROGRAMDATA%. On Windows Vista this results in: C:\ProgramData.
According to http://dev.mysql.com/doc/refman/5.6/en/option-files.html, the first location MySQL will look under is in %PROGRAMDATA%\MySQL\MySQL Server 5.6\my.ini. In your Windows shell if you do ls "%PROGRAMDATA%\MySQL\MySQL Server 5.6\my.ini", you will see that the file is there.
Unlike most suggestions you will find in Stackoverflow and around the web, putting the file in C:\Program Files\MySQL\MySQL Server 5.6\my.ini WILL NOT WORK. Neither will C:\Program Files (x86)\MySQL\MySQL Server 5.1. The reason being quoted on the MySQL link posted above:
On Windows, MySQL programs read startup options from the following
files, in the specified order (top items are used first).
The 5.6 MSI installer does create a my.ini in the highest priority location, meaning no other file will ever be found/used, except for the one created by the installer.
The solution accepted above will not work for 5.6 MSI-based installs.
Enter "services.msc" on the Start menu search box.
Find MySQL service under Name column, for example, MySQL56.
Right click on MySQL service, and select Properties menu.
Look for "Path To Executable" under General tab, and there is your .ini file, for instance, "C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.6\my.ini" MYSQL56
I've found mine in
\ProgramData\MySQL\MySQL Server 8.0\
(It is a hidden folder)
You can type win+R and write %PROGRAMDATA% to access that folder, or just enable show hidden folder.
You have to look I the folder C:\Program Files\MySQL\MySQL Server 5.5 but there is a problem. When you perform an MSI install of MySQL, my.ini is not created. There will be sample .ini files in that folder. In order to use one of them, say my-medium.ini, you need to do the following before a MySQL restart:
cd C:\Program Files\MySQL\MySQL Server 5.5
copy my-medium.ini my.ini
net stop mysql
net start mysql
Once, you do this, my.ini can be read by C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe.
Start MySQL Workbench, then Server -> Options File and look at bottom of the window; it will say something like "Configuration File: C:\ProgramData\MySQL\MySQL Server 5.6\my.ini"
(And note the subtle difference between "ProgramData" and "Program Files" - easy to gloss over if you're looking for a quick answer.)
Answered for only MySQL Workbench users,
You can find the my.ini file in windows at this location-
C:\ProgramData\MySQL\MySQL Server 5.6
the ProgramData folder is a hidden folder, so make the according setting to see that folder.
And open my.ini file as an administrator to edit and then save that.
In my case, the folder ProgramData was hidden by default on windows 7, so I was unable to find my.ini file.
After selecting show hidden files and folders option, I was able to find the my.ini file at the location: C:\ProgramData\MySQL\MySQL Server 5.6.
Display hidden files and folders on windows 7:
Right-click the Windows Logo button and choose Open Windows Explorer.
Click Organize and choose Folder and Search Options.
Click the View tab, select Show hidden files and folders and then clear the checkbox for Hide protected system operating files.
Click Yes on the warning and then click OK.
Press the windows key > type services > press enter > Look up mysql in the list > right click > properties > Path to Executable will have the location of the defaults file right below it (my.ini)
it is there at C:\Program Files\MySQL\MySQL Server 5.5 there are various .ini files with small, medium & large names. generally medium is used or it depends on your requirement.
programData is hidden folder so you have to change the option from setting to show hidden folder and then make the change in my.ini file present in that.
Be sure to update the correct my.ini file because it can waste a lot of your time if you keep updating wrong file.
You can look into service to see which my.ini is configured in this service.
Open your run console
type: services.msc
look for: mysql
right click
properties
where is written "path to executable", click and move the cursor to the right until you see the directory of my.ini, it's written "defaults-file-".
to reach it manually on your explore folders you have to enable the visualization of hidden elements (explore folder>top menu>visualize>visualize hidden elements)
as explained by this video
https://www.youtube.com/watch?v=SvCAa2XuQhg
on Windows if MySQL is install as a service you can change the binpath of the service. For example
sc config MySQL57 binPath= "\"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe\" --defaults-file=\"<myini path>" MySQL57"
space after binpath is important. You must escape double quotes
MySQL and MariaDB
According to the documentation of both MySQL and MariaDB you need to run mysql with --help --verbose to know the location of the my.ini file
Go to the command or terminal
cd yourMySQLBinDirectory
mysqld --verbose --help
You will see large output but first few lines will show the order the server is looking for the file. I got the following response. It will be different for your computer or server.
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 D:\Databases\mariadb-10.3.30-winx64\my.ini D:\Databases\mariadb-10.3.30-winx64\my.cnf D:\Databases\mariadb-10.3.30-winx64\data\my.ini D:\Databases\mariadb-10.3.30-winx64\data\my.cnf
I met with the same problem when I did MSI install of MySQL and there were no my-medium.ini files too when I tried the above steps. Only installing the ZIP file of MySQL helped me. So, I suggest you to uninstall the MSI installed folder and reinstall using the ZIP file.
For MySql Server 8.0 The default location is %WINDIR% or C:\Windows.
You need to add a "my.ini" file there.
Here's a sample of what I put in the ini file.
[mysqld]
secure_file_priv=""
Make sure to restart the MySQL service after that.

where is mysql server's default data folder in windows 7

I am looking for the data directory of mysql server (5.1.42) I installed on my machine which runs win7.
There is no 'data' direcotory in C:\Program Files\MySQL\MySQL Server 5.1 and also in C:\Users\MyAccount\AppData\Local||LocalLow||Roaming
Different MySQL/Windows versions have different data folder locations. To get your ACTUAL data folder location just execute this SQL:
SHOW VARIABLES WHERE Variable_name LIKE '%dir'
Must be C:\ProgramData\MySQL\MySQL Server 5.1\data.
Was not really a good idea to place data here by default. It is compatible with various Vista compatibility requirements, but is eather hard to find, especially given the ProgramData folder is hidden.
You can find the data directory at this location
C:\ProgramData\MySQL\MySQL Server 5.5\data\<YourDataDirectory\TableName.frm>
The path can be defined in my.ini (located in Windows directory) as datadir.
I have had the problem to find the data directory too and even to start the mysql the second time after installing the server 5.7 on Windows 7.
In contrary to some answers here and to the documentation (the part about location of my.ini), the my.ini location was c:\ProgramData\MySQL\MySQL Server 5.7\my.ini the data location was c:\ProgramData\MySQL\MySQL Server 5.7\Data. In fact it was to see, as default proposed data location, during the installation.
This is what worked for me on Windows 7:
c:\ProgramData\MySQL\MySql Server 5.7> xcopy data c:\MySQL\"MySQL Server 5.7"\data\
After that, run MySQL server with:
c:\MySQL\"MySQL Server 5.7"\bin> mysqld
Thanks to those who shared the information that C:\ProgramData was a hidden directory!
If you installed mysql with the MSI installer,
look here: C:\ProgramData\MySQL\MySQL Server 5.7\ and you should see the data folder.
Even thought my datadir is specified to be located in the default mysql server location, my data is stored in %ProgramData%.
Windows version independent answer.
For MySQL 5.7 on Windows, directory for log files and databases is
"%PROGRAMDATA%\MySQL\MySQL Server 5.7\"
The Windows system variable
%PROGRAMDATA% defaults to C:\ProgramData
source: https://dev.mysql.com/doc/refman/5.7/en/windows-installation-layout.html
After changing the directory, the root password is reset. So, keep in mind, if you change the directory, and have access issues, try to access it without a password then set a new password.
For newer users: The data directory lies in C:\Program Files\MySQL\MySQL Server 8.0\data
I currently have MySQL Server 8.0. If you too, are searching for some error solutions and couldn't find the "data" directory for MySQL, here's a note from the official MySQL:
"The default data directory location is C:\Program Files\MySQL\MySQL Server 8.0\data, or C:\ProgramData\Mysql on Windows 7 and Windows
Server 2008. The C:\ProgramData directory is hidden by default. You
need to change your folder options to see the directory and contents."
Hope this clears some hurdles
Take a look at:
C:\Users\All Users\MySQL\MySQL Server 5.1\data