How to Fix MySQL 8.0 Startup Failure After Ubuntu 20.04 Upgrade: Solving “unknown variable ‘query_cache_limit'” Error


4 views

After upgrading to Ubuntu 20.04 LTS with MySQL 8.0, many users encounter a startup failure due to deprecated configuration parameters. The key error message in /var/log/mysql/error.log shows:

2020-11-12T16:12:26.377752Z 0 [ERROR] [MY-000067] [Server] unknown variable 'query_cache_limit=1M'.
2020-11-12T16:12:26.378449Z 0 [ERROR] [MY-010119] [Server] Aborting

This occurs because MySQL 8.0 completely removed the query cache feature that existed in previous versions, making any related configuration parameters invalid.

Edit your MySQL configuration file:

sudo nano /etc/mysql/my.cnf

Alternatively, check if you have configuration in:

/etc/mysql/mysql.conf.d/mysqld.cnf
/etc/mysql/conf.d/*

Remove or comment out these lines:

# query_cache_limit = 1M
# query_cache_size = 16M
# query_cache_type = 1

While fixing this issue, you should also check for other deprecated parameters:

expire-logs-days → replace with binlog_expire_logs_seconds
innodb_file_format → removed in MySQL 8.0
innodb_file_format_check → removed in MySQL 8.0

After making changes, restart MySQL:

sudo systemctl restart mysql

Check the status:

sudo systemctl status mysql

Examine the logs again:

sudo tail -f /var/log/mysql/error.log

If your WordPress site remains in maintenance mode after fixing MySQL, remove the maintenance file:

sudo rm /var/www/html/.maintenance

Or if using a different document root:

sudo rm /path/to/your/wordpress/.maintenance

Before performing major system upgrades:

1. Backup your databases:
   mysqldump -u root -p --all-databases > all-databases-backup.sql

2. Review MySQL's deprecation notes:
   https://dev.mysql.com/doc/relnotes/mysql/8.0/en/

3. Check current configuration against new version requirements:
   mysqld --verbose --help | grep -A 1 "deprecated"

For performance tuning after removing query cache:

# Recommended alternatives in MySQL 8.0
[mysqld]
performance_schema = ON
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M

When upgrading to Ubuntu 20.04 LTS, many users encounter MySQL startup failures with the error message unknown variable 'query_cache_limit=1M'. This occurs because MySQL 8.0 (the default version in Ubuntu 20.04) has completely removed the query cache feature that existed in previous versions.

To get MySQL running again, you'll need to modify your MySQL configuration file:

sudo nano /etc/mysql/my.cnf
# Or if that doesn't exist:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Locate and remove these lines (if present):

query_cache_limit=1M
query_cache_size=16M
query_cache_type=1

The log also shows another deprecation warning about expire-logs-days. Update this to the new parameter:

# Replace:
# expire-logs-days=10
# With:
binlog_expire_logs_seconds=864000

After making these changes, restart MySQL:

sudo systemctl restart mysql
sudo systemctl status mysql

Check your error log to confirm successful startup:

sudo tail -f /var/log/mysql/error.log

For WordPress sites using MySQL 8.0, consider these performance optimizations instead of query cache:

[mysqld]
innodb_buffer_pool_size=1G
innodb_flush_log_at_trx_commit=2
innodb_flush_method=O_DIRECT
innodb_read_io_threads=4
innodb_write_io_threads=4

If you're migrating from an older MySQL version, you might need to dump and reload your databases to ensure compatibility:

mysqldump -u root -p --all-databases --routines --triggers > full_backup.sql
mysql_upgrade -u root -p
# After making configuration changes

MySQL 8.0 removed query cache because it caused scalability issues on multi-core systems and often hurt performance more than it helped. The development team recommends using alternative optimization techniques like proper indexing and query optimization instead.