Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.2Mb
PDF (A4) - 37.2Mb
PDF (RPM) - 36.9Mb
EPUB - 10.5Mb
HTML Download (TGZ) - 10.3Mb
HTML Download (Zip) - 10.3Mb
HTML Download (RPM) - 8.9Mb
Eclipse Doc Plugin (TGZ) - 11.1Mb
Eclipse Doc Plugin (Zip) - 13.3Mb
Man Pages (TGZ) - 203.8Kb
Man Pages (Zip) - 309.1Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
Excerpts from this Manual Creating an Option File

If you need to specify startup options when you run the server, you can indicate them on the command line or place them in an option file. For options that are used every time the server starts, you may find it most convenient to use an option file to specify your MySQL configuration. This is particularly true under the following circumstances:

  • The installation or data directory locations are different from the default locations (C:\Program Files\MySQL\MySQL Server 5.7 and C:\Program Files\MySQL\MySQL Server 5.7\data).

  • You need to tune the server settings, such as memory, cache, or InnoDB configuration information.

When the MySQL server starts on Windows, it looks for option files in several locations, such as the Windows directory, C:\, and the MySQL installation directory (for the full list of locations, see Section 5.2.6, “Using Option Files”). The Windows directory typically is named something like C:\WINDOWS. You can determine its exact location from the value of the WINDIR environment variable using the following command:

C:\> echo %WINDIR%

MySQL looks for options in each location first in the my.ini file, and then in the my.cnf file. However, to avoid confusion, it is best if you use only one file. If your PC uses a boot loader where C: is not the boot drive, your only option is to use the my.ini file. Whichever option file you use, it must be a plain text file.


When using the MySQL Installer to install MySQL Server, it will create the my.ini at the default location, and the user executing MySQL Installer is granted full permissions to this new my.ini file.

In other words, be sure that the MySQL Server user has permission to read the my.ini file.

You can also make use of the example option files included with your MySQL distribution; see Section 6.1.2, “Server Configuration Defaults”.

An option file can be created and modified with any text editor, such as Notepad. For example, if MySQL is installed in E:\mysql and the data directory is in E:\mydata\data, you can create an option file containing a [mysqld] section to specify values for the basedir and datadir options:

# set basedir to your installation path
# set datadir to the location of your data directory

Microsoft Windows path names are specified in option files using (forward) slashes rather than backslashes. If you do use backslashes, double them:

# set basedir to your installation path
# set datadir to the location of your data directory

The rules for use of backslash in option file values are given in Section 5.2.6, “Using Option Files”.

As of MySQL 5.7.6, the Zip Archive no longer includes a data directory. To initialize a MySQL installation by creating the data directory and populating the tables in the mysql system database, initialize MySQL using either --initialize or --initialize-insecure. For additional information, see Section, “Initializing the Data Directory Manually Using mysqld”.

If you would like to use a data directory in a different location, you should copy the entire contents of the data directory to the new location. For example, if you want to use E:\mydata as the data directory instead, you must do two things:

  1. Move the entire data directory and all of its contents from the default location (for example C:\Program Files\MySQL\MySQL Server 5.7\data) to E:\mydata.

  2. Use a --datadir option to specify the new data directory location each time you start the server.

User Comments
  Posted by Dave Johnson on April 21, 2007
If you have installed mysql using xampp, moving your data directory is not a matter of creating a new option file, but modifying the one used by xampp to start your mysql server.

Look for the batch file mysql_start.bat in the xampp directory. My mysql_start.bat file includes this line:
mysql\bin\mysqld --defaults-file=mysql\bin\my.cnf --standalone --console

By editing the mysql\bin\my.cnf file (that path is relative to the xampp installation directory), I was able to change the default data directory.
  Posted by Katy Kringe on February 24, 2016
You have to be careful with Windows 7 (and above I presume). If you try and edit a My.INI file in the program directory, Windows will save it in C:\Users\<yourname>\AppData\Local\VirtualStore\Program Files (x86) instead. Whenever you try and open it from the editor it appears to be in the right place ( C:\Program Files (x86) ), when you look for it with windows explorer it isn't.

The solution is to edit it in a working directory, then copy it into C:\Program Files (x86), making the appropriate gesture to Micro$oft as you do so.
  Posted by Alex Kersha on August 6, 2016
@Katy Kringe - if you simply start your editor with Administrator privileges, you can save the file anywhere you want.
Sign Up Login You must be logged in to post a comment.