Common SQL Errors

MySQL Error 49: EE_WRONG_DIRECTIVE_IN_CONFIG_FILE - How to Fix Wrong '!%s' Directive Issues

Galaxy Team
August 5, 2025

MySQL cannot start because my.cnf contains an invalid or misplaced !include or !includedir directive.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error code 49?

MySQL Error 49: EE_WRONG_DIRECTIVE_IN_CONFIG_FILE means the server found an invalid !include or !includedir directive in my.cnf. Remove or correct the directive path, place it in the proper section, then restart MySQL to fix the issue.

Error Highlights

Typical Error Message

Wrong '!%s' directive in config file %s at line %d. EE_WRONG_DIRECTIVE_IN_CONFIG_FILE was added in 8.0.13.

Error Type

Configuration Error

Language

MySQL

Symbol

EE_WRONG_DIRECTIVE_IN_CONFIG_FILE

Error Code

49

SQL State

Explanation

Table of Contents

What is MySQL Error 49: EE_WRONG_DIRECTIVE_IN_CONFIG_FILE?

MySQL raises this global error when it parses a configuration file and encounters an unsupported, misspelled, or context-invalid directive beginning with an exclamation mark. The server stops reading the file and aborts startup.

The message shows the bad directive, the file path, and the exact line number, helping administrators locate the misconfiguration quickly.

Why does this error matter?

The server will not start or will ignore the entire configuration block, leading to default settings, security gaps, or downtime.

Fixing the directive is essential for normal operation and predictable behavior.

What Causes This Error?

Misplaced !include or !includedir directives inside option groups other than [mysqld] trigger the error because the parser allows them only at the global scope.

Typos such as !incldue or unsupported directives like !sys_var create the same failure because MySQL cannot interpret them.

Using relative paths that resolve outside allowed directories or pointing to non-existent files also causes MySQL to reject the directive.

How to Fix MySQL Error 49

Open the file named in the message, navigate to the reported line, and verify the directive spelling.

Ensure you use exactly !include or !includedir.

Move the directive outside any section headers or place it at the top of the file before the first [group].

Provide an absolute path to a readable file or directory. Confirm permissions allow the mysql user to read the included files.

Common Scenarios and Solutions

Docker containers often mount custom my.cnf files that reference host-only paths.

Use container-internal paths or copy the file into the image to eliminate the error.

Automated configuration tools may append !includedir directives inside template blocks.

Adjust the template to insert directives at the top level.

Best Practices to Avoid This Error

Keep one primary my.cnf and place all !include statements at the very beginning to guarantee correct parsing order.

Validate configuration changes with mysqld --verbose --help --no-defaults --defaults-file=/path/to/my.cnf 2>&1 | less before restarting production servers.

Version-control configuration files and use CI checks that run mysqld --initialize-insecure to catch directive errors early.

Related Errors and Solutions

ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option - arises when file paths fall outside secure_file_priv.

mysqld: unknown option '--something' - appears when an option is placed in the wrong group or is deprecated.

.

Common Causes

Related Errors

FAQs

Can I use relative paths with !include?

Relative paths work but are risky. Always prefer absolute paths to avoid resolution errors, especially inside Docker or systemd services.

Does the directive order matter?

Yes. Directives must precede any option groups or MySQL ignores them and raises error 49.

Will MySQL ignore the rest of the file after this error?

The server stops parsing the file and aborts startup, so none of the remaining options are applied.

How does Galaxy help avoid this error?

Galaxy surfaces MySQL startup logs inside its integrated terminal, highlighting configuration errors instantly so developers can correct them before deploying changes.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo