I can't find the file "my.cnf" or "my.ini" - mysql

I installed version 8 of MySQL and I can't find the configuration file
I was reading and everyone says that it is inside the "MySQL Server x.0" folder, but in my case it does not appear, neither inside the "etc" or "bin" folder

How I found mine was like this;
mysqld --help --verbose | grep my.cnf

I guess you are on Windows because of the "MySQL Server x.0" folder name (on Mac & Linux, this folder name does not contain spaces by default).
No configuration file is created after a standard installation. You may create one if you have the need to specify any options. Otherwise every option has a default setting built into the MySQL Server.
On Windows, the MySQL Server searches several locations for the configuration file, so you can put the file in any of those locations.
See documentation for a list of the locations the server searches for the configuration file on Windows:
https://dev.mysql.com/doc/refman/8.0/en/windows-create-option-file.html
https://dev.mysql.com/doc/refman/8.0/en/option-files.html
Remember that after you edit the configuration file, you need to restart the MySQL Server. It reads the configuration options only when the server starts.

On Windows my.ini file will be auto generated when you install MySQL server. It will be located in a hidden directory ProgramData.
C:\ProgramData\MySQL\MySQL Server 8.0
In order to view these files you may need to show hidden items. To do that
Open file explorer > View > Tick Hidden Items

Related

MySQL Workbench Unable to Retrieve Disk Space in Data Dir, Server Stopped

I had mySQL workbench working fine a few weeks ago. Now, any time I log in, I get no connection. Upon inspecting Sever Status, it is showing Stopped. Also, under the Server Directories, it says Unable to Retrieve next to Disk Space in Data Dir.
I also noticed that the configuration file was wrong, or outdated? The Configuration File originally read:
C:\ProgramData\MySQL\MySQL Server 5.5\my.ini
But I looked and there was no MySQL Server 5.5 file in my directory. I do have a MySQL Server 8.0 folder, so I changed the Configuration File to:
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
However, this fails to solve the problem. I've also attempted to run Services from the Start Menu, right click on MYSQL80, and choose start - and it says the service has Started then stopped.
I'm not even sure this missing or mis-directed file is the issue, or whether it's the Unable to Retrieve Disk error (or both are causing the server to fail). I recently changed my login password for my computer - but I doubt that is related to the login credentials for MySQL, right? (I see MYSQL80 properties has password for 'log on' option, but I have no idea what this password even is, or how to change it).
I've also read about this problem online and cannot seem to find an answer that solves the issue. I've tried running MySQL Workbench as an admin too, and that doesn't work either.
Can anyone point me in the right direction? Is there a way to get the server up and running again without a bunch of complicated command line? I appear to have mysqld.exe in the bin file in MySQL 8.0
Thanks all in advance!
In MySql Workbench Server -> Startup/ShutDown -> Start Server.
This Worked for me.
When the my.ini file is messed up I think the best solution is a total uninstall/delete and manual install. Before you do any of the following make sure you go to your current data dir and save your database folders. Then dlete all of your current MySQL related directories and uninstall MySQL and MySQL workbench.
I had this problem when I installed MySQL 8.0.15 with the community installer. The my.ini file that came with the installer did not work correctly after it had been edited. I did a full manual install by downloading that zip folder. I was able to create my own my.ini file containing only the parameters that I was concerned about and it worked.
download zip file from MySQL website
unpack the folder into C:\program files\MySQL\MySQL8.0
within the MySQL8.0 folder that you unpacked the zip folder into, create a text file and save it as my.ini
include the parameters in that my.ini file that you are concerned about. so something like this(just ensure that there is already a folder created for the datadir or else initialization won't work):
[mysqld]
basedire=C:\program files\MySQL\MySQL8.0
datadir=D:\MySQL\Data
....continue with whatever parameters you want to include
initialize the data directory by running these two commands in the command prompt:
cd C:\program files\MySQL\MySQL8.0\bin
mysqld --default-file=C:\program files\MySQL\MySQL8.0\my.ini --initialize
install the MySQL server as a service by running these two commands:
cd C:\program files\MySQL\MySQL8.0\bin
mysqld --install --default-file=C:\program files\MySQL\MySQL8.0\my.ini
finally, start the server for the first time by running these two commands:
cd C:\program files\MySQL\MySQL8.0\bin
mysqld --console

After Installing SQL - How and Where do I create a my.cnf file for My Windows OS

I'm a beginner to SQL and setting up my environment.
I installed SQL on my windows 10 machine and the next step I need to do is create a my.cnf file (exact instructions: Create a my.cnf file in one of the default locations mysql is looking for it on your OS)
I do not know how and where to set this my.cnf file on my windows 10 machine. Can someone please help?
follow the following steps.
Type services.msc.
Find MySQL service in the services section.MYSQL56 is SQL service.Right click on it and go for properties.
Under general tab under properties, you will find the path of the default file in the path to executable.
Then locate the MYSQL configuration file i.e my.cnf on windows platform.You will easily find the file in this way on windows platform.
At the same level directory where your project is, create a file Auth and inside that create mysql.cnf .
And in your settings.py give the full path of above file inside databases' default option.

MySql configuration file does not exist where WorkBench says so

I'm new to MySql. I have downloaded and installed MySql 5.6 together with the latest version of Workbench (6.2). Workbench says my configuration file is in
C:\Program Files\MySQL\MySQL Server 5.0\my.ini
This folder does not exist. I have
C:\Program Files\MySQL\MySQL Server 5.6
And inside this folder there is an .ini file called my-default.ini. How can I find the correct .ini file so I can change my variables?
The name and path used by MySQL Workbench by default is taken from a template. There are several templates for various server versions and platforms with typical config file locations. However, they may not always work. On Windows however, with standard installations (which are extremely common), there are only very few variations. The simplest way to have the correct config file stored in the connection settings is by changing the installation type in the System Profile settings for a connection:
The sample config file my-default.ini is just that, an example. The installer should have created a concrete config file in the ProgramData MySQL folder for your server, which is what MySQL Workbench will also use by default.
For someone wants to find the menu answered above,
It can be found when you right click on a connection instance box of your MySQL workbench home and go to edit connection.
I know this question posted 5 years ago, but I had looked for the menu as well and finally find it. I hope I can add a comment but I cannot due to the reputation;)

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