Common SQL Errors

MySQL Error 1651: ER_QUERY_CACHE_DISABLED - Causes and Fixes

Galaxy Team
August 7, 2025

<p>MySQL raises Error 1651 when the server’s query cache is turned off but a statement or tool tries to access it.</p>

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 1651 ER_QUERY_CACHE_DISABLED?

<p>MySQL Error 1651 ER_QUERY_CACHE_DISABLED means the query cache subsystem is off. Edit my.cnf to set query_cache_type=1 and query_cache_size>0, then restart MySQL to resolve the issue.</p>

Error Highlights

Typical Error Message

Query cache is disabled; restart the server with

Error Type

Configuration Error

Language

MySQL

Symbol

ER_QUERY_CACHE_DISABLED

Error Code

1651

SQL State

HY000

Explanation

Table of Contents

What is MySQL Error 1651 ER_QUERY_CACHE_DISABLED?

MySQL throws Error 1651 with the message 'Query cache is disabled; restart the server with query_cache_type=1 to enable it' when it detects that the query cache subsystem is inactive yet referenced by a statement or monitoring tool.

The error is informational but blocks cache-related operations such as SHOW STATUS LIKE 'Qcache%'. It normally appears right after server start or during performance checks.

What Causes This Error?

A global setting of query_cache_type=0 or query_cache_size=0 disables the cache. MySQL then refuses any cache interaction and emits the 1651 code.

The error is common after upgrading to MySQL 8.0, where the query cache feature was removed entirely. Legacy configuration lines or scripts still referencing it will fail immediately.

How to Fix MySQL Error 1651 ER_QUERY_CACHE_DISABLED

For MySQL 5.7 or earlier, edit my.cnf to set query_cache_type=1 and allocate a positive query_cache_size, then restart the server.

For MySQL 8.0 and later, delete all query cache variables from configuration files and code. Adopt indexing, query rewrites, or external caches like Redis for performance instead.

Common Scenarios and Solutions

Migration scripts that call RESET QUERY CACHE stop with this error. Wrap such commands in a version check or remove them for MySQL 8.0.

Monitoring tools querying Qcache metrics on a disabled server will spam logs. Update tool settings to skip cache metrics or re-enable the cache.

Best Practices to Avoid This Error

Maintain consistent configuration across environments so query_cache_type and query_cache_size values match. Validate during CI using SHOW VARIABLES.

Run mysql_upgrade before version changes and scan for deprecated parameters. Document performance requirements early to select the right caching strategy.

Related Errors and Solutions

Error 1630 FUNCTION NOT FOUND may appear after upgrades that drop unused plugins. Verify functions before updates.

Error 1203 Too many connections signals insufficient max_connections. Increase it and monitor usage.

Common Causes

Disabled query_cache_type

Setting query_cache_type=0 forces MySQL to bypass the cache, triggering Error 1651 whenever cache operations are requested.

Zero query_cache_size

A query_cache_size of 0 allocates no memory, effectively disabling the cache and causing the error.

Upgrade to MySQL 8.0

The query cache was removed in MySQL 8.0. Any remaining references immediately raise Error 1651.

Custom Scripts Using RESET QUERY CACHE

Maintenance scripts that call RESET QUERY CACHE on a server where the cache is off will receive the error.

Related Errors

MySQL Error 1631: ER_SP_DOES_NOT_EXIST

Raised when a stored procedure is missing or misspelled. Create or correct the procedure.

MySQL Error 1203: ER_TOO_MANY_USER_CONNECTIONS

Occurs when a user exceeds the allowed connections. Increase max_user_connections or optimize pooling.

MySQL Error 2006: MySQL server has gone away

Indicates the connection was lost due to timeouts or packet limits. Adjust wait_timeout and max_allowed_packet.

FAQs

Can I enable the query cache in MySQL 8.0?

No. MySQL 8.0 removed the feature entirely. You must remove related settings and use alternative caching strategies.

Is the query cache recommended for high-write workloads?

Generally no. Heavy writes cause frequent cache invalidation, reducing benefit. Rely on indexes and application-level caching instead.

How do I know if the cache is helping performance?

Monitor Qcache_hits and Qcache_inserts after enabling the cache. A high hit ratio indicates benefit.

Does Galaxy support checking query cache settings?

Yes. Galaxy’s editor lets you run SHOW VARIABLES and share results with your team, ensuring everyone sees the same configuration.

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