Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
VGSources
Blog

How to Find and Edit the MySQL my.ini or my.cnf File

Use MySQL's own help output and service arguments to locate the active my.ini or my.cnf, then edit server and client options with the right groups, precedence and restart procedure.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The active MySQL configuration is not always the file you expect. On Windows it is usually named my.ini; on Linux and macOS it is usually my.cnf. The reliable method is to ask the exact MySQL executable for its option-file search list, then inspect the service command for an explicit --defaults-file or --defaults-extra-file. Once you identify the file that is actually read, edit it as plain text using the correct option group and restart the server when the setting is startup-only.

What my.ini and my.cnf do

my.ini and my.cnf are MySQL option files. They hold startup options for the server and for client programs, so you do not have to type the same command-line switches every time MySQL starts. A command-line option such as --port=3307 is written in an option file as port=3307, under the group that should receive it.

As an Amazon Associate I earn from qualifying purchases.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The filename is not a dependable way to identify the active configuration. MySQL can read several files in sequence, and a package, service definition, container entry point, or administrator can add an explicit file. Later values normally override earlier values. A file can therefore exist on disk without being used, or a value in a later file can make an earlier edit appear to have no effect.

The same distinction matters for scope. The [mysqld] group is for the server, [mysql] is for the classic mysql client, and [client] is read by MySQL client programs but not by mysqld. Program-specific groups can target an individual utility.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

The authoritative way to discover the active search list

Do not begin by guessing a path from a forum post. MySQL’s own help output is tied to the executable you are running and shows the default option-file locations for that installation.

  1. Open a terminal or Command Prompt.
  2. Run the client executable with --help. For the server, run mysqld --verbose --help.
  3. Find the section headed Default options are read from the following files.
  4. Record the order shown. MySQL processes files in that order, and a later definition generally wins.
  5. Check the command that starts the server for --defaults-file, --defaults-extra-file, or an included configuration directory.

Use the same binary and service instance that will run your workload. A client installed with a development package can have a different search list from a server binary installed by a separate package. Likewise, two MySQL server instances on one machine can use different files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understanding explicit file options

--defaults-file=path points the program at a specific option file and can change the normal search behavior. Treat it as authoritative for that process. --defaults-extra-file=path adds an extra file to the normal processing sequence, usually late enough to override a value from a general file. Inspect the actual service or launch command instead of assuming either option is absent.

Where MySQL looks on Windows

On Windows, the documented search sequence includes these locations. The exact list printed by your executable takes precedence over this general map.

Order Location or source What it is used for
1 %WINDIR%my.ini or %WINDIR%my.cnf System-wide option file in the Windows directory
2 C:my.ini or C:my.cnf Option file at the root of the system drive
3 Copies under the MySQL BASEDIR Files placed with the MySQL installation
4 An explicitly supplied --defaults-extra-file An additional file named by the startup command
5 %APPDATA%MySQL.mylogin.cnf Client login-path data created by mysql_config_editor
6 DATADIRmysqld-auto.cnf Server-persisted variables managed by MySQL

MySQL checks each location for the relevant file. If a file exists, its options are read; definitions encountered later can override earlier definitions. The Windows guide describes the name preference at a location as checking my.ini first and then my.cnf.

Check the Windows directory instead of assuming it

The Windows directory is commonly C:WINDOWS, but the value can differ. In Command Prompt, run:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
echo %WINDIR%

Use the printed directory when checking the first search location. Environment variables can also affect where a particular installation keeps its base or data directory.

MySQL Configurator’s current default

MySQL Configurator currently places my.ini under C:ProgramDataMySQLMySQL Server 26.7 by default. This is an installer default, not a guarantee that every Windows installation uses that path. Confirm it with the executable’s help output and the service definition.

Windows procedure

  1. Open Command Prompt. Change to the MySQL bin directory if mysqld.exe is not on PATH.
  2. Run mysqld --verbose --help. If the server executable requires a full path, run that path in quotes.
  3. Copy the displayed option-file list into your notes.
  4. Open the Windows Services console and locate the MySQL service. Inspect its executable path or service properties for an explicit --defaults-file or --defaults-extra-file.
  5. Check the candidate files in the printed order. The file that contains the final definition may be different from the first file you find.
  6. Open the intended file in a text editor. Notepad is sufficient; run the editor with an account that can save in the directory.

If the service runs under a restricted account, your administrator permissions for editing do not automatically grant the service permission to read a new data or log path. Keep the file readable by the account that starts MySQL.

Where MySQL looks on Linux, macOS, and other Unix-like systems

For Unix-like systems, the documented sequence is:

Order Location or source Scope or note
1 /etc/my.cnf System-wide configuration
2 /etc/mysql/my.cnf Common package-managed location
3 SYSCONFDIR/my.cnf Compile-time system configuration directory
4 $MYSQL_HOME/my.cnf Server-specific location when MYSQL_HOME is used
5 An explicitly supplied --defaults-extra-file Additional file named at startup
6 ~/.my.cnf User option file, generally for client use
7 ~/.mylogin.cnf Client login-path data, not ordinary text
8 DATADIR/mysqld-auto.cnf Server-managed persisted variables

Distribution packages often add !include or !includedir directives. A short /etc/mysql/my.cnf may therefore pull in files from another directory. Read those directives before deciding which file supplies a value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Unix procedure

  1. Run mysqld --verbose --help for the server and mysql --help for the client you intend to use.
  2. Read the default-file section exactly as printed by each program.
  3. Inspect the service unit, launch script, or process arguments for --defaults-file and --defaults-extra-file.
  4. Open each candidate file and follow every !include and !includedir directive.
  5. Check ownership and permissions. MySQL ignores configuration files that are world-writable on Unix-like systems; remove the world-write permission and give ownership to the appropriate administrative account.

Included-directory order is not guaranteed. Unix included files must end in .cnf; on Windows, MySQL checks .ini and .cnf. If two included files set the same option, do not rely on a filename sort order that the server does not promise.

How to edit an option file safely

An option file is plain text. Use a group header, then one option per line. Do not copy the command-line double dash into the file.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
[mysqld]
port=3307
max_connections=250
max_allowed_packet=128M

[client]
port=3307

Choose the correct group

  • [mysqld]: server startup options such as the listening port, data directory, connection limit, and InnoDB settings.
  • [mysql]: options for the mysql command-line client.
  • [client]: options shared by MySQL client programs; mysqld does not read this group.
  • Program-specific groups: settings intended for one named utility.

Group names are case-insensitive. An option placed in a valid file but in the wrong group can look as though MySQL ignored it.

Precedence and duplicate options

MySQL normally uses the last value it processes for a repeated option. This is why a correct edit can have no visible effect: a later file, an included file, or a command-line argument may set the option again. The server’s first user option is a documented security exception to the usual replacement rule, so do not treat it as an ordinary duplicate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Windows path syntax

Prefer forward slashes in Windows option values:

basedir=C:/Program Files/MySQL/MySQL Server 26.7
datadir=C:/ProgramData/MySQL/MySQL Server 26.7/Data

If you use backslashes, double them where an escape sequence could be interpreted:

datadir=C:ProgramDataMySQLMySQL Server 26.7Data

A single backslash can introduce an escape sequence. Quoting and escaping rules are therefore important when a path contains spaces or backslashes.

Comments and included files

Use # or ; for comments. A specific file can be inserted with !include path. A directory can be inserted with !includedir path. Keep included files in the extension format required by the operating system and make sure every referenced path is readable by the process that starts MySQL.

Editing common settings

Changing the server port

Put the port in [mysqld] so the server listens on it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
[mysqld]
port=3307

Client programs do not automatically discover a changed server port. Add the same value to [client] if the local MySQL clients should default to that port:

[client]
port=3307

After the server restarts, verify that applications, firewall rules, connection strings, and monitoring tools use the new port. A client-only change does not move the server, and a server-only change can make existing clients attempt the old port.

Changing max_connections

Set the startup default in the server group:

[mysqld]
max_connections=250

The value limits concurrent client connections, but it does not guarantee that every connection attempt succeeds: operating-system limits, memory, authentication, and thread resources still matter. Keep the unitless integer and avoid placing this option in [client]. If you change it in the file, restart the server when your installation requires a restart for the new startup value.

Changing datadir

The data directory is a server setting:

[mysqld]
datadir=C:/ProgramData/MySQL/MySQL Server 26.7/Data

On Unix, use an absolute path such as:

[mysqld]
datadir=/var/lib/mysql

Changing datadir is not merely a text edit. The target must contain the expected MySQL data layout, and the account that runs the server must be able to traverse and read it and write required files. Treat a move as a migration: stop the instance using its normal service manager, copy or restore the data consistently, update the option and any service-specific path, then start the same instance and inspect its error log if startup fails.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Changing InnoDB settings

InnoDB options belong in [mysqld]. For example:

[mysqld]
innodb_buffer_pool_size=1G
innodb_log_file_size=512M

Use the exact option spelling accepted by the MySQL version installed on the machine. Memory and redo-log settings can affect startup requirements and disk usage, so change one related setting at a time and keep a backup of the working file. Some variables can be changed dynamically, but an option-file edit is a startup default; use the server’s documented runtime mechanism when you need an immediate change.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Files you should not edit as ordinary text

.mylogin.cnf

.mylogin.cnf stores encrypted login-path data created by mysql_config_editor. It is not a normal readable option file. Do not open it in a text editor or paste ordinary options into it. Manage login paths with the tool that created them.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

mysqld-auto.cnf

mysqld-auto.cnf is JSON maintained by the server after SET PERSIST or SET PERSIST_ONLY. MySQL specifically says management of this file should be left to the server. Do not hand-edit its JSON. If a persisted variable is wrong, use the appropriate SQL persistence statement or remove the persisted value through MySQL’s supported interface, then let the server rewrite the file.

How to verify that an edit took effect

  1. Save a backup copy of the original file and record the exact option, group, and value you changed.
  2. Run the server’s help command again and confirm that you edited a file in the active search list.
  3. Check for an explicit --defaults-file, an extra file, command-line options, and !include directives that can override your value.
  4. Restart the correct MySQL service when the option is read only at startup. Restarting a client does not restart the server.
  5. Connect to that server instance and inspect the relevant variable with the normal MySQL variable display statement. Confirm the value from the instance you intended, not from another local or remote server.
  6. Review the error log if startup fails. A syntax error, unknown option, inaccessible path, invalid permission, or conflicting setting is usually reported there.

For a setting that is intentionally persisted through SQL, distinguish the runtime value from the text file. A value shown by the server can come from a persisted setting in mysqld-auto.cnf, a conventional option file, or a command-line override.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting: when MySQL appears to ignore the file

You edited a plausible path, but nothing changed

  • Run mysqld --verbose --help for the exact server binary and compare its search list with the path you edited.
  • Inspect the service definition for --defaults-file or --defaults-extra-file.
  • Search all later files and included directories for a second copy of the option.
  • Confirm the option is under [mysqld], not a client-only group.
  • Restart the server instance, then verify the value from that instance.

The server refuses to start after the edit

  • Restore the backup file or remove the last change to regain service.
  • Check spelling, numeric units, and whether the installed MySQL version supports the option.
  • Check that datadir, included files, and log paths exist and are accessible to the service account.
  • Read the error log for the first reported cause rather than fixing only the final cascade error.

A Unix file is silently ignored

Check whether the file is world-writable. MySQL ignores configuration files with unsafe world-write permissions on Unix-like systems. Correct the ownership and permissions, then start the server again.

Two installations or services are present

Match three things before editing: the executable shown by the service, the data directory used by that service, and the option-file list printed by that executable. A system can have a package-managed server, a manually installed server, and separate client tools, each with different defaults.

Best practices for repeatable configuration changes

  • Capture the help output before making changes so the active search order is documented.
  • Keep one authoritative file for site-wide defaults when possible, and use included files only when their ownership and precedence are clear.
  • Place server settings in [mysqld] and shared client defaults in [client]; avoid putting secrets in broadly readable files.
  • Use comments to record why a non-default value exists, but never comment out a later override and assume an earlier value will win.
  • Change one setting at a time, restart only the intended service, and verify the resulting variable from a connection to that service.
  • Never manually modify .mylogin.cnf or mysqld-auto.cnf.

The dependable answer to “Where is my.ini or my.cnf?” is therefore not a single universal path. It is the search list reported by the program that starts your MySQL instance, combined with the service’s explicit arguments and any include directives. Use that evidence, apply the option in the correct group, account for later overrides, and let MySQL manage its encrypted and persisted files.

Frequently Asked Questions

Can I rename my.cnf to my.ini?

The filename alone does not determine whether MySQL reads a file. Use the executable’s displayed search list and the service arguments; keep the documented filename and location for your installation unless you deliberately configure an explicit file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why does my client still connect to the old port after I edit [mysqld]?

The server and clients have separate groups. Set the server port in [mysqld] and the client default in [client], then restart the server and update applications that supply their own connection port.

Is mysqld-auto.cnf a replacement for my.cnf?

No. It is server-managed JSON for values saved with SET PERSIST or SET PERSIST_ONLY. Do not edit it manually; use MySQL’s persistence statements to change those values.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.