MySQL error 29 (EE_FILENOTFOUND) occurs when the database server cannot locate a required file. This commonly happens with LOAD DATA INFILE operations, when accessing database table files, or due to file permission restrictions.
Error 29 is MySQL's generic "file not found" error, represented by the symbol EE_FILENOTFOUND. The full error message format is "File '%s' not found (OS errno %d - %s)", which includes the filename and the underlying operating system error code. This error indicates that MySQL attempted to access a file but failed to locate it. The file could be a data file you're trying to import (LOAD DATA INFILE), a database table file (.MYD, .MYI, .frm), or a configuration file. The specific OS errno included in the error message provides additional context about why the operating system couldn't find the file—common codes include errno 2 (file doesn't exist) and errno 13 (permission denied). Unlike permission-only errors, EE_FILENOTFOUND encompasses multiple scenarios: the file genuinely doesn't exist at the specified path, MySQL is looking in the wrong directory, security configurations prevent access, or file system permissions block MySQL from seeing the file.
First, confirm the file actually exists at the location you specified:
# On Linux/Mac
ls -la /path/to/your/file.csv
# On Windows
dir C:\path\to\your\file.csvFor LOAD DATA operations, use an absolute path instead of a relative path to eliminate ambiguity:
-- Use absolute path
LOAD DATA INFILE '/var/lib/mysql-files/data.csv'
INTO TABLE your_table
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n';On Windows, use forward slashes or escaped backslashes:
-- Forward slashes (recommended)
LOAD DATA INFILE 'C:/data/file.csv'
INTO TABLE your_table;
-- Or escaped backslashes
LOAD DATA INFILE 'C:\\data\\file.csv'
INTO TABLE your_table;If your file is on the client machine (not the MySQL server), you must use LOAD DATA LOCAL INFILE:
-- For files on your local machine
LOAD DATA LOCAL INFILE '/home/user/data.csv'
INTO TABLE your_table
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;Without LOCAL, MySQL expects the file to be on the database server host. With LOCAL, the MySQL client reads the file and sends it to the server.
The local_infile setting controls whether LOAD DATA LOCAL INFILE is allowed. Check if it's enabled:
SHOW GLOBAL VARIABLES LIKE 'local_infile';If it shows OFF, enable it:
SET GLOBAL local_infile = 1;To make this permanent, add to your MySQL configuration file:
# In /etc/mysql/my.cnf or /etc/my.cnf (Linux)
# Or C:\ProgramData\MySQL\MySQL Server 8.0\my.ini (Windows)
[mysqld]
local-infile=1
[mysql]
local-infile=1After editing the config file, restart MySQL:
# Linux (systemd)
sudo systemctl restart mysql
# Linux (older systems)
sudo service mysql restart
# Windows
net stop MySQL80
net start MySQL80MySQL Workbench: Edit your connection, go to the Advanced tab, and add OPT_LOCAL_INFILE=1 in the "Others:" box.
MySQL's secure-file-priv setting restricts file operations to a specific directory. Check the current setting:
SHOW VARIABLES LIKE 'secure_file_priv';Possible values:
- A directory path: You can only load files from this directory
- Empty string: No restrictions (not recommended for production)
- NULL: File operations are completely disabled
If a directory is set, move your file there:
# Common secure-file-priv directories
# Linux: /var/lib/mysql-files/
# Windows: C:\ProgramData\MySQL\MySQL Server 8.0\Uploads\
sudo cp /path/to/data.csv /var/lib/mysql-files/
sudo chown mysql:mysql /var/lib/mysql-files/data.csvTo change the secure-file-priv directory (requires restart), edit your my.cnf:
[mysqld]
secure-file-priv = "/path/to/your/data/directory"Note: Setting secure-file-priv = "" disables restrictions but creates security risks.
MySQL must have read access to the file. Set appropriate permissions:
# Make file readable by MySQL
sudo chmod 644 /path/to/file.csv
# Make directory accessible
sudo chmod 755 /path/to/directory
# Change ownership to mysql user (if needed)
sudo chown mysql:mysql /path/to/file.csvVerify permissions:
ls -la /path/to/file.csv
# Should show: -rw-r--r-- mysql mysqlOn Windows, right-click the file → Properties → Security tab, and ensure the MySQL service account has Read permissions.
If you're on Ubuntu or Debian, AppArmor may be blocking MySQL file access even when permissions are correct. Check AppArmor status:
sudo aa-status | grep mysqlTo allow MySQL to access your directory, edit the local AppArmor profile:
sudo nano /etc/apparmor.d/local/usr.sbin.mysqldAdd your directory (replace with your actual path):
/path/to/your/data/** r,Reload the AppArmor profile:
sudo systemctl reload apparmor
# Or
sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqldTemporary testing: Switch MySQL to complain mode (logs violations but doesn't block):
sudo aa-complain /usr/sbin/mysqldIf this fixes the issue, AppArmor was the problem. Switch back to enforce mode after updating the profile:
sudo aa-enforce /usr/sbin/mysqldSELinux Considerations: On Red Hat/CentOS/Fedora systems with SELinux enabled, similar restrictions apply. Check SELinux context:
ls -Z /path/to/file.csvSet the correct context:
sudo semanage fcontext -a -t mysqld_db_t "/path/to/data(/.*)?"
sudo restorecon -Rv /path/to/dataDatabase File Recovery: If the error references missing .MYD or .MYI files, your database tables may be corrupted. Try repairing:
REPAIR TABLE your_table;
CHECK TABLE your_table;For MyISAM tables with completely missing files, you may need to restore from backups.
Docker Considerations: When mounting existing database directories in Docker, ensure the volume mount is correct and the MySQL user (UID 999 by default) has access:
sudo chown -R 999:999 /path/to/mysql/dataSymbolic Links: If using symlinks for database directories or data files, MySQL must be configured to follow them with the symbolic-links=1 option, though this is disabled by default for security reasons.
FILE Privilege: For non-LOCAL LOAD DATA operations, your MySQL user needs the FILE privilege:
GRANT FILE ON *.* TO 'your_user'@'localhost';
FLUSH PRIVILEGES;However, FILE is a sensitive privilege that allows reading any file the MySQL server can access. Grant it carefully.
ERROR 1064: You have an error in your SQL syntax
How to fix "ERROR 1064: You have an error in your SQL syntax" in MySQL
ERROR 1054: Unknown column in field list
Unknown column in field list
ER_WINDOW_RANGE_FRAME_NUMERIC_TYPE (3589): RANGE frame requires numeric ORDER BY expression
RANGE frame requires numeric ORDER BY expression in MySQL window functions
CR_ALREADY_CONNECTED (2058): Handle already connected
How to fix "CR_ALREADY_CONNECTED (2058): Handle already connected" in MySQL
ER_WINDOW_DUPLICATE_NAME (3591): Duplicate window name
How to fix ER_WINDOW_DUPLICATE_NAME (3591) in MySQL window functions