Error
Error Code: 49

MySQL Error 49: Invalid Configuration Directive

📦 MySQL
📋

Description

This error signifies that MySQL has detected an unrecognized or malformed directive within its configuration file, such as `my.cnf` or `my.ini`. It typically occurs during MySQL server startup, preventing the database from initializing correctly due to a syntax or content error at a specified line.
💬

Error Message

Wrong '!%s' directive in config file %s at line %d.
🔍

Known Causes

4 known causes
⚠️
Typographical Error
A simple spelling mistake or incorrect capitalization in a directive's name or value within the configuration file.
⚠️
Unsupported Directive
The configuration file contains a directive that is deprecated, removed, or not recognized by the specific MySQL server version being used.
⚠️
Incorrect Directive Syntax
The directive itself is valid, but its arguments, values, or overall structure do not conform to the expected syntax for MySQL configuration files.
⚠️
Malformed Comment
An improperly formatted comment line is mistakenly interpreted by MySQL as an executable directive, leading to a syntax error.
🛠️

Solutions

3 solutions available

1. Correct Typos in Configuration File easy

Identify and fix spelling or syntax errors in your MySQL configuration file.

1
Locate your MySQL configuration file. Common locations include `/etc/my.cnf`, `/etc/mysql/my.cnf`, `/etc/mysql/mysql.conf.d/mysqld.cnf`, or within the MySQL data directory on Windows.
2
Open the configuration file in a text editor.
3
The error message 'Wrong '!%s' directive' indicates a malformed directive. Look for lines that start with `!` followed by unexpected characters or syntax. For example, a typo like `!bind-address` instead of `bind-address` or an incorrect placeholder like `!my_variable` where a valid directive is expected.
Example of an incorrect line: `!bind-address = 127.0.0.1`
Example of a correct line: `bind-address = 127.0.0.1`
4
Correct any identified typos or syntax errors. Ensure each directive follows the standard MySQL configuration format (e.g., `directive = value`).
5
Save the changes to the configuration file.
6
Restart the MySQL service for the changes to take effect.
For systemd-based systems:
sudo systemctl restart mysql

For SysVinit-based systems:
sudo service mysql restart

For Windows:
Open services.msc, find the MySQL service, and restart it.

2. Remove or Comment Out Problematic Include Directives medium

If the error points to an include file, isolate and correct the issue within that file.

1
Examine the error message carefully. It often specifies the configuration file and line number where the 'Wrong '!%s' directive' occurred. If the line involves an `!include` or `!includedir` directive, this is your starting point.
2
Navigate to the specified configuration file and line number. If the problematic line is an `!include` directive, open the file it points to.
Example: If the error is on line 15 of `my.cnf` and it says `!include /etc/mysql/conf.d/custom.cnf`, open `/etc/mysql/conf.d/custom.cnf`.
3
Within the included file, apply the same troubleshooting steps as in 'Correct Typos in Configuration File' to identify and fix any invalid directives.
4
Alternatively, if you suspect a specific included file is causing the problem and you can't immediately fix it, you can temporarily comment out the `!include` directive in the main configuration file by adding a `#` at the beginning of the line.
Example: Change `!include /etc/mysql/conf.d/custom.cnf` to `# !include /etc/mysql/conf.d/custom.cnf`
5
Save the changes and restart the MySQL service.
For systemd-based systems:
sudo systemctl restart mysql

For SysVinit-based systems:
sudo service mysql restart
6
If commenting out the include resolves the issue, you know the problem lies within that included file. Further investigate that file's contents.

3. Verify MySQL Version Compatibility medium

Ensure your configuration directives are compatible with your installed MySQL version.

1
Determine the exact version of your MySQL server. You can usually find this by running:
mysql --version
2
Consult the official MySQL documentation for your specific version (e.g., MySQL 8.0, MySQL 5.7). Pay close attention to the configuration options available and their syntax.
Example: Search for 'MySQL [your_version] server system variables' or 'MySQL [your_version] configuration file options'.
3
Review your `my.cnf` (or equivalent) file for any directives that might have been deprecated, removed, or had their syntax changed in your MySQL version. Directives that were valid in older versions might cause this error in newer ones.
4
Remove or update any incompatible directives according to the documentation for your MySQL version.
5
Save the configuration file and restart the MySQL service.
For systemd-based systems:
sudo systemctl restart mysql

For SysVinit-based systems:
sudo service mysql restart
🔗

Related Errors

5 related errors