Common SQL Errors

MySQL Error 12: EE_DIR - Can't read dir of '%s' (OS errno %d - %s) - How to Fix and Prevent

Galaxy Team
August 5, 2025

MySQL cannot read the referenced directory because the operating system returned a failure such as permission denied, missing path, or filesystem corruption.

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 code 12 (EE_DIR)?

MySQL Error 12: EE_DIR means the server failed to read a directory named in the message. Check OS errno for the root cause, restore directory permissions or create the missing path, then retry the statement to resolve the issue.

Error Highlights

Typical Error Message

Can't read dir of '%s' (OS errno %d - %s)

Error Type

Filesystem Error

Language

MySQL

Symbol

EE_DIR

Error Code

12

SQL State

Explanation

Table of Contents

What is MySQL Error 12 (EE_DIR)?

MySQL raises Error 12 with condition EE_DIR when it tries to scan or open a directory and the operating system denies access. The full text is "Can't read dir of '%s' (OS errno %d - %s)", where %s expands to the directory path and the final placeholder shows the OS error description.

The error surfaces during file-based operations such as LOAD DATA, SELECT ... INTO OUTFILE, log rotation, or table discovery on disk.

Because the engine depends on the filesystem, correcting the underlying OS problem is crucial for server stability.

What Causes This Error?

Permission mismatches, missing directories, SELinux/AppArmor policies, and hardware issues lead the kernel to refuse directory reads. MySQL only relays the errno and cannot continue, so the client receives Error 12 immediately.

Using containerized deployments amplifies the risk because volume mounts may be read-only or mis-mapped.

Large instances also encounter inode exhaustion, which blocks directory access even when space remains.

How to Fix MySQL Error 12 (EE_DIR)

Start with the OS errno shown in the message. Errno 13 signals permission denied, while Errno 2 indicates no such file or directory. Correct the root cause on the host, verify ownership (usually mysql:mysql), and reopen the directory. Restarting the server is rarely required once the path is readable.

After fixing permissions, re-run the failed SQL statement to confirm resolution.

For repeat issues, add a health check that scans the path and alerts before MySQL encounters it.

Common Scenarios and Solutions

Load data workflows often specify an incorrect directory in LOCAL INFILE commands. Adjust the secure_file_priv setting or copy the file into the permitted folder.

Binlog or relay-log directories moved during migrations may be missing. Update my.cnf (log_bin, relay_log) and create the directories with correct ownership.

Best Practices to Avoid This Error

Store all MySQL-managed directories under a dedicated parent owned by the mysql user.

Automate permission checks in deployment scripts.

Galaxy’s desktop SQL editor lets engineers centralise vetted LOAD DATA and OUTFILE queries in shared Collections. Endorsed queries reduce typos and ensure paths comply with secure_file_priv, preventing EE_DIR before it happens.

Related Errors and Solutions

Error 29 (OS errno 13 - Permission denied) appears when reading a file, not a directory. Fix it by adjusting file permissions similarly.

Error 1030 (HY000 - Got error X from storage engine) can wrap EE_DIR on older versions.

Inspect the MySQL error log to reveal the underlying errno and repair the directory path.

.

Common Causes

Related Errors

FAQs

Does Error 12 always mean a permission issue?

No. Errno 2 means the directory is missing, while Errno 30 means the filesystem is read-only. Interpret the errno before acting.

Can I fix EE_DIR without restarting MySQL?

Yes. Once the directory becomes readable, the server continues normally. Only redo the failed SQL statement.

How does secure_file_priv relate to EE_DIR?

If secure_file_priv is set, MySQL refuses to read or write outside that folder. Referencing another directory triggers EE_DIR with Errno 13.

How can Galaxy help avoid this error?

Galaxy centralises endorsed queries, allowing admins to approve paths that comply with secure_file_priv. Shared context prevents developers from using invalid directories.

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