MySQL my.cnf file - Found option without preceding group
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
The MySQL error Found option without preceding group means the parser found a configuration line before it knew which section it belonged to. In my.cnf, every option must appear under a group header such as [mysqld] or [client]; a bare option at the top level is invalid.
How my.cnf Is Structured
MySQL option files are organized into named groups. Each group header is written in square brackets, and every setting beneath it belongs to that group until the next header appears.
Valid example:
Broken example:
The first line causes the error because it appears before any group header.
The Groups Matter
The group tells MySQL which program the options apply to. Common groups include:
- '
[mysqld]for the server' - '
[client]for client programs' - '
[mysql]for themysqlCLI' - '
[mysqldump]formysqldump'
Putting the option under the wrong group may not trigger this specific error, but it can still lead to silent misconfiguration because the intended program never reads it.
The Most Common Causes
This error usually comes from one of a small number of formatting problems:
- an option line appears before the first group
- a group header is missing brackets
- a copied config fragment starts with an option instead of a section
- an included file is malformed
- a hidden byte-order mark or stray characters appear before the first
[header
A malformed header is enough:
It should be:
Fix the File by Making the Structure Explicit
The repair is usually simple: move every option under a valid section and keep related settings grouped together.
Example corrected file:
Avoid dumping unrelated server and client settings into one section just because it makes the file shorter. The grouping is part of the meaning.
Watch Out for Included Config Fragments
Many MySQL or MariaDB installations load additional files from directories such as /etc/mysql/conf.d/ or /etc/mysql/mariadb.conf.d/. A syntax error in one included fragment can surface as a startup failure for the whole service.
For example, a fragment like this is invalid:
It must still start with a group:
When the main file looks fine, inspect every included file as well.
Validate Before Restarting Blindly
Do not restart the server repeatedly without checking which option file is failing. Use MySQL tooling to inspect effective defaults and parser behavior.
One useful check is:
If the option file is malformed, the tool will complain instead of printing parsed defaults. On systemd systems, the service logs are also valuable:
That usually points you toward the exact file and line area that broke startup.
Keep the File Boring
A configuration file is not the place for cleverness. Keep these rules:
- start every fragment with a group header
- keep comments on their own lines or after valid settings
- avoid copying snippets from blog posts without checking the section they belong to
- do not mix server and client options casually
The less surprising the file layout is, the easier it is to diagnose later.
Common Pitfalls
The most common mistake is pasting a single option into my.cnf or a conf.d fragment without a section header.
Another mistake is assuming the main file is the only file that matters. Included fragments are parsed too, and one bad fragment can block MySQL startup.
Developers also sometimes typo the section header itself by forgetting the square brackets. The file still looks visually reasonable, but the parser no longer sees a group.
Finally, watch for editor artifacts in copied files. Hidden characters at the top of the file can make a valid header look invalid to the parser.
Summary
- '
Found option without preceding groupmeans an option appeared before a valid section header.' - Every
my.cnfsetting must live under a group such as[mysqld]or[client]. - The same rule applies to included config fragments, not just the main file.
- Validate with tools such as
my_print_defaultsand inspect service logs before guessing. - Keep configuration files structurally simple so parser errors stay obvious.

