# mysql error: performance_schema is not enabled - how to turn it on

## TL;DR

performance_schema is off, so all the lock, wait, and stage instrumentation is missing. Turn it on in the config (performance_schema=ON) and restart; there is no reliable way to enable the full schema at runtime on most builds.

```text
ERROR 1227 (42000): Access denied; performance_schema is not enabled or not properly configured
```

## Steps

1. Check the current state: SHOW VARIABLES LIKE 'performance_schema'.
   Expected: It reads OFF.

2. Add performance_schema=ON to the [mysqld] section of my.cnf.
   Expected: The setting is in the config file.

3. Restart MySQL. A restart is required; the schema initializes at startup.
   Expected: The server comes back with the schema populated.

4. Verify: SELECT COUNT(*) FROM performance_schema.threads.
   Expected: It returns a nonzero count instead of an error or zero rows.

5. Trim overhead if needed: leave the schema on but disable consumers you do not use via the setup_consumers table.
   Expected: Instrumentation stays available with minimal cost.

## When to use

- performance_schema queries error out or return empty
- you need data_locks, events_waits, or events_statements tables
- a monitoring agent complains about missing instrumentation

## When not to use

- the tables exist but are empty for your workload (check setup_consumers, not the global switch)
- you only need the processlist (information_schema works without it)
- you are on a tiny instance where every percent of CPU matters (measure before leaving everything on)

## Tool compatibility

- MySQL 5.7 and 8.0, MariaDB 10.5+
- config file: my.cnf under [mysqld]

## Variant phrasings

- "mysql performance_schema is not enabled fix"
- "turn on performance_schema mysql"
- "performance_schema OFF enable without restart"

## Why it happens

performance_schema is the instrumentation layer behind lock tables, wait events, and statement digests. Many builds ship with it off to save memory, and several consumers default off even when the schema is on. Without it, every lock and wait diagnostic in this series has nothing to read.

## Edge cases

- on MySQL 8.0 the schema is on by default; finding it off usually means someone disabled it deliberately, so ask why before flipping it
- setup_instruments and setup_consumers control what is actually collected; the global switch alone may not populate the table you want
- memory overhead scales with table sizes; on constrained instances enable only the consumers you need

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_T3uFV_R7WIp8iOsN-QOmOw
