MySQL & MariaDB error 1290: The MySQL server is running with an option so it cannot execute this statement
The MySQL server is running with the --secure-file-priv option so it cannot execute this statement (5.6.51) · The MariaDB server is running with the --read-only option so it cannot execute this statement (10.6.28) A server setting blocks the statement. Most often --secure-file-priv (INTO OUTFILE / LOAD DATA outside the allowed directory) or --read-only (writes on a replica). The message names the option.
| MySQL | MariaDB | |
|---|---|---|
| Symbol | ER_OPTION_PREVENTS_STATEMENT | ER_OPTION_PREVENTS_STATEMENT |
| SQLSTATE | HY000 | HY000 |
| Type | Server error | Server error |
| Versions | every release since 5.0 active | every release since 5.5 active |
What it means
The statement is valid, but a server option forbids it. The end of the message says which one: --secure-file-priv, --read-only, --super-read-only or --skip-grant-tables.
Why it happens
--secure-file-priv:SELECT … INTO OUTFILE,LOAD DATA INFILE(withoutLOCAL) andLOAD_FILE()may only use the directory in@@secure_file_priv. Packaged MySQL sets it to a directory such as/var/lib/mysql-files/;NULLdisables file operations completely. The official MariaDB Docker images leave it empty, so thereINTO OUTFILEworks anywhere the server process can write (tested on 10.6–11.8).--read-only: the server is a replica, or a former primary that was demoted. Accounts withoutSUPER/CONNECTION_ADMINcan’t write. Withsuper_read_onlyeven administrators can’t.--skip-grant-tables: while the server runs without privilege checking (for a password reset), account statements likeCREATE USERandALTER USERfail untilFLUSH PRIVILEGES.
How to fix it
SELECT @@secure_file_priv;and write or read inside that directory. To change it, setsecure_file_privin my.cnf and restart; it can’t be changed at runtime.- Use client-side alternatives that don’t involve the server’s file system:
mysql -e "SELECT …" > out.tsv,mysqldump --tab, orLOAD DATA LOCAL INFILE(see 3948). - For read-only: send writes to the primary. Check with
SELECT @@read_only, @@super_read_only;and only turn it off on a server that is meant to be the primary. - After
--skip-grant-tables, runFLUSH PRIVILEGES;first, then the account statement.
Reproduce it yourself
These steps are the exact test our harness runs. Use a scratch server, never production.
Connect with
mysql -u root -pand create a scratch database and the test data:CREATE DATABASE demo; USE demo; CREATE TABLE t (a INT); INSERT INTO t VALUES (1);As an admin, create a normal account and make the server read-only.
CREATE USER 'appuser'@'%' IDENTIFIED BY 'Test#1234'; GRANT INSERT ON demo.* TO 'appuser'@'%'; SET GLOBAL read_only = 1;Write as the normal account. Admin accounts (SUPER / CONNECTION_ADMIN) are not blocked unless super_read_only is also on.
mysql -u appuser -p -h 127.0.0.1 demo -e 'INSERT INTO t VALUES (2)'Put it back.
SET GLOBAL read_only = 0;
You get: ERROR 1290 (HY000) at line 1: The MariaDB server is running with the --read-only option so it cannot execute this statement(11.8.9)
Verified fixes
Check secure_file_priv and write inside that directory
SELECT @@secure_file_priv; SELECT a INTO OUTFILE '/var/lib/mysql-files/out_demo.csv' FROM t;cat /var/lib/mysql-files/out_demo.csv
Tested on
| Step | MySQL | MariaDB | |||||||
|---|---|---|---|---|---|---|---|---|---|
| 5.6 | 5.7 | 8.0 | 8.4 | 9 | 10.6 | 10.11 | 11.4 | 11.8 | |
| SELECT ... INTO OUTFILE to /tmp with each server's default secure_file_priv (MariaDB images leave it empty, so it works) version check | ✗ 1290 | ✗ 1290 | ✗ 1290 | ✗ 1290 | ✗ 1290 | ✓ | ✓ | ✓ | ✓ |
| A normal account writes while the server is read_only (a replica, or a failed-over primary) repro | ✓ 1290 | ✓ 1290 | ✓ 1290 | ✓ 1290 | ✓ 1290 | ✓ 1290 | ✓ 1290 | ✓ 1290 | ✓ 1290 |
| Check secure_file_priv and write inside that directory fix | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
What the warnings and failures say (1)
- SELECT ... INTO OUTFILE to /tmp with each server's default secure_file_priv (MariaDB images leave it empty, so it works) (MySQL 5.6, MySQL 5.7, MySQL 8.0, MySQL 8.4, MySQL 9): error 1290: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
Related errors
Where this error shows up in our guides
- LOAD DATA INFILE · LOAD DATA INFILE '/tmp/product.csv' as root (original path) MySQL 5.6 5.7 8.0 8.4 9
- LOAD DATA INFILE with auto_increment · LOAD DATA INFILE 'name.txt' (relative path) ... (name) (original) MySQL 5.6 5.7 8.0 8.4 9
- OUTFILE syntax · SELECT ... INTO OUTFILE '/tmp/...' (original) MySQL 5.6 5.7 8.0 8.4 9
- LOAD DATA INFILE variable data · Relative file name 'upload1.csv' as in the post MySQL 5.6 5.7 8.0 8.4 9
- OUTFILE required permissions · INTO OUTFILE into a directory the server can't write (ERROR 1 Errcode 13; MySQL images stop it earlier with 1290) MySQL 5.6 5.7 8.0 8.4 9