mysqldude

OUTFILE required permissions

Version compatibility

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
INTO OUTFILE as a user without FILE privilege (1045 on 5.x, clearer 1227 on 8.0+/MariaDB)
original post
✓ 1045✓ 1045✓ 1227✓ 1227✓ 1227✓ 1227✓ 1227✓ 1227✓ 1227
GRANT FILE ON *.* then INTO OUTFILE (original)
original post
✓✓✓✓✓✓✓✓✓
GRANT FILE ON db.* (FILE is global only, expect 1221)
version check
✓ 1221✓ 1221✓ 1221✓ 1221✓ 1221✓ 1221✓ 1221✓ 1221✓ 1221
INTO OUTFILE into a directory the server can't write (ERROR 1 Errcode 13; MySQL images stop it earlier with 1290)
original post
✓ 1290✓ 1290✓ 1290✓ 1290✓ 1290✓ 1✓ 1✓ 1✓ 1
INTO OUTFILE as a user without FILE privilege (1045 on 5.x, clearer 1227 on 8.0+/MariaDB) original post
MySQL 5.6✓ 10455.7✓ 10458.0✓ 12278.4✓ 12279✓ 1227
MariaDB 10.6✓ 122710.11✓ 122711.4✓ 122711.8✓ 1227
GRANT FILE ON *.* then INTO OUTFILE (original) original post
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
GRANT FILE ON db.* (FILE is global only, expect 1221) version check
MySQL 5.6✓ 12215.7✓ 12218.0✓ 12218.4✓ 12219✓ 1221
MariaDB 10.6✓ 122110.11✓ 122111.4✓ 122111.8✓ 1221
INTO OUTFILE into a directory the server can't write (ERROR 1 Errcode 13; MySQL images stop it earlier with 1290) original post
MySQL 5.6✓ 12905.7✓ 12908.0✓ 12908.4✓ 12909✓ 1290
MariaDB 10.6✓ 110.11✓ 111.4✓ 111.8✓ 1
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9

Related errors: 1045, 1221, 1290

The original article

First published 2012-05-08. The text below is the original; the table above shows how it behaves on current versions.

In order to use MySQL’s OUTFILE requires the user to have FILE privilege. The FILE privilege is not assigned on a per database but at a system level, hence the use of ’.’.

mysql> grant FILE on *.* TO ronan@localhost;
Query OK, 0 rows affected (0.06 sec)

Be sure that the folder that you are exporting to is writable by the MySQL server user. Here is an example of what is returned if you attempt to write to a folder that does not have the correct permissions:

mysql> select * into outfile '/home/toto.txt' from t1;
ERROR 1 (HY000): Can't create/write to file '/home/toto.txt' (Errcode: 13)