The error you're encountering is quite specific:
[ERROR] /usr/sbin/mysqld: unknown option '--query_cache_size-128M'
This indicates MySQL is trying to parse an invalid configuration parameter. What's particularly puzzling is that this option doesn't appear in your my.cnf file. Let's investigate why this might be happening.
MySQL reads configuration from multiple locations in a specific order:
- /etc/my.cnf
- /etc/mysql/my.cnf
- $MYSQL_HOME/my.cnf
- ~/.my.cnf
Even though you've checked your primary my.cnf, the invalid parameter might be coming from:
!includedir /etc/mysql/conf.d/
Run this command to search for configuration files that might contain the problematic parameter:
grep -r "query_cache_size-128M" /etc/mysql/
Alternatively, check all active MySQL options with:
mysqld --verbose --help
The error suggests a syntax issue. The correct way to specify query cache size is:
query_cache_size = 128M
Note the:
- Single hyphen (not double)
- Equals sign
- No leading dashes
To quickly get MySQL running while you investigate:
sudo mysqld --skip-query-cache
Or edit your configuration to completely disable the query cache:
query_cache_size = 0
query_cache_type = 0
To see exactly how MySQL is interpreting your configuration:
mysqld --print-defaults
This will show all active parameters, which might reveal where the invalid option is coming from.
- Configuration File Inheritance: Check all included files in /etc/mysql/conf.d/
- Command Line Parameters: Verify if any startup scripts are passing invalid options
- Upgrade Artifacts: If you recently upgraded MySQL, old configuration might persist
- Copy-Paste Errors: The parameter might have been accidentally modified
Here's how to properly set up query cache configuration:
# Query Cache Configuration
query_cache_limit = 1M
query_cache_size = 16M
query_cache_type = 1
Remember that as of MySQL 8.0, the query cache is deprecated and removed. If you're using a newer version, you should remove all query cache related parameters entirely.
When attempting to start MySQL on Ubuntu, you encountered this critical error:
[ERROR] /usr/sbin/mysqld: unknown option '--query_cache_size-128M'
[ERROR] Aborting
Your my.cnf shows a properly formatted query_cache_size setting:
query_cache_limit = 1M
query_cache_size = 16M
Yet MySQL is complaining about an entirely different parameter format that doesn't appear in your configuration.
In my experience troubleshooting similar issues, these are the most likely culprits:
1. Multiple Configuration Files
MySQL can read from multiple locations. Check these additional files:
$ sudo find / -name "*.cnf" -exec grep -l "query_cache_size" {} \;
$ mysql --help | grep -A1 "Default options"
2. Command Line Parameters
Check if any startup scripts are injecting parameters:
$ ps aux | grep mysql
$ cat /etc/init.d/mysql
3. Version Compatibility Issues
The hyphenated format suggests possible version mismatch:
$ mysqld --version
Debugging with --verbose
Start MySQL with verbose logging:
$ mysqld --verbose --help
Temporary Configuration Override
Try starting with a minimal config:
$ mysqld --defaults-file=/path/to/minimal.cnf
Sample minimal.cnf:
[mysqld]
datadir=/var/lib/mysql
socket=/var/run/mysqld/mysqld.sock
Configuration Directory Check
Examine included directories:
$ ls -la /etc/mysql/conf.d/
$ cat /etc/mysql/conf.d/*.cnf
If standard approaches fail, consider these advanced techniques:
Configuration File Precedence
MySQL reads files in this order:
/etc/my.cnf
/etc/mysql/my.cnf
~/.my.cnf
Binary Log Inspection
Examine the actual parameters being used:
$ strace -f -e trace=open mysqld_safe
Last Resort: Clean Installation
If corrupted configuration is suspected:
$ sudo apt-get purge mysql-server
$ sudo rm -rf /etc/mysql
$ sudo apt-get install mysql-server
To avoid similar issues:
# Always validate configuration before restarting
$ mysqld --validate-config
# Use proper parameter formatting (no hyphens)
query_cache_size = 128M
not query_cache_size-128M