Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-30 · container image mysql:8.4
ERROR 1290 means the server was started (or set) with an option that blocks this kind of statement, and the message names the option. On MySQL 8.4 the most common one is --secure-file-priv: SELECT ... INTO OUTFILE and LOAD DATA INFILE may only use files in one folder. In this Docker image @@secure_file_priv is /var/lib/mysql-files/.
The same code with --read-only in the message means the server is not accepting writes.
01SELECT ... INTO OUTFILE to a path outside secure_file_priv
Exporting with INTO OUTFILE '/tmp/orders.csv' failed with ERROR 1290. SELECT @@secure_file_priv returned /var/lib/mysql-files/, the only folder the server may write to.
Writing to '/var/lib/mysql-files/orders.csv' instead returned "Query OK, 2 rows affected".
Setup
\! rm -f /var/lib/mysql-files/orders.csv
CREATE DATABASE shop;
CREATE TABLE shop.orders (order_id INT PRIMARY KEY, status VARCHAR(10));
INSERT INTO shop.orders VALUES (1, 'NEW'), (2, 'PAID');Query OK, 1 row affected (0.01 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0SELECT order_id, status FROM shop.orders
INTO OUTFILE '/tmp/orders.csv' FIELDS TERMINATED BY ',';ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statementSELECT @@secure_file_priv;+-----------------------+
| @@secure_file_priv |
+-----------------------+
| /var/lib/mysql-files/ |
+-----------------------+
1 row in set (0.00 sec)The file is written on the database server, not on your PC. If you need the file on the client side, export with a client tool instead.
SELECT order_id, status FROM shop.orders
INTO OUTFILE '/var/lib/mysql-files/orders.csv' FIELDS TERMINATED BY ',';
\! rm -f /var/lib/mysql-files/orders.csvQuery OK, 2 rows affected (0.00 sec)02LOAD DATA INFILE from a path outside secure_file_priv
LOAD DATA INFILE '/tmp/orders.csv' failed with the same message. Loading the file from /var/lib/mysql-files/orders.csv read 2 records into orders_copy (Skipped: 0, Warnings: 0).
Setup
\! rm -f /var/lib/mysql-files/orders.csv
CREATE DATABASE shop;
CREATE TABLE shop.orders (order_id INT PRIMARY KEY, status VARCHAR(10));
CREATE TABLE shop.orders_copy LIKE shop.orders;
INSERT INTO shop.orders VALUES (1, 'NEW'), (2, 'PAID');
SELECT order_id, status FROM shop.orders INTO OUTFILE '/var/lib/mysql-files/orders.csv' FIELDS TERMINATED BY ',';Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
Query OK, 2 rows affected (0.00 sec)LOAD DATA INFILE '/tmp/orders.csv' INTO TABLE shop.orders_copy FIELDS TERMINATED BY ',';ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statementSELECT @@secure_file_priv;+-----------------------+
| @@secure_file_priv |
+-----------------------+
| /var/lib/mysql-files/ |
+-----------------------+
1 row in set (0.00 sec)LOAD DATA INFILE '/var/lib/mysql-files/orders.csv' INTO TABLE shop.orders_copy FIELDS TERMINATED BY ',';
SELECT order_id, status FROM shop.orders_copy;
\! rm -f /var/lib/mysql-files/orders.csvQuery OK, 2 rows affected (0.00 sec)
Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
+----------+--------+
| order_id | status |
+----------+--------+
| 1 | NEW |
| 2 | PAID |
+----------+--------+
2 rows in set (0.00 sec)03INSERT on a server where read_only is ON
With SET GLOBAL read_only = ON, an INSERT by the normal user lab_a failed with ERROR 1290, this time naming the --read-only option. SELECT @@read_only, @@super_read_only returned 1 and 0.
After SET GLOBAL read_only = OFF, the same INSERT worked.
Setup
CREATE TABLE orders (order_id INT PRIMARY KEY, status VARCHAR(10));Query OK, 0 rows affected (0.01 sec)SET GLOBAL read_only = ON;Query OK, 0 rows affected (0.00 sec)INSERT INTO orders VALUES (1, 'NEW');ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statementSELECT @@read_only, @@super_read_only;+-------------+-------------------+
| @@read_only | @@super_read_only |
+-------------+-------------------+
| 1 | 0 |
+-------------+-------------------+
1 row in set (0.00 sec)SET GLOBAL read_only = OFF;Query OK, 0 rows affected (0.00 sec)read_only is usually on for a reason (a replica or a server being switched over). Check that you are connected to the right server before turning it off.
INSERT INTO orders VALUES (1, 'NEW');
SELECT order_id, status FROM orders;Query OK, 1 row affected (0.01 sec)
+----------+--------+
| order_id | status |
+----------+--------+
| 1 | NEW |
+----------+--------+
1 row in set (0.00 sec)FAQ
How do I fix --secure-file-priv option so it cannot execute this statement?
Run SELECT @@secure_file_priv; and use a file path inside that folder for INTO OUTFILE and LOAD DATA INFILE. In our MySQL 8.4 container it was /var/lib/mysql-files/.
Where is the secure_file_priv folder?
It depends on how MySQL was installed. Always check with SELECT @@secure_file_priv; on the server.
Why does ERROR 1290 mention --read-only?
The server has read_only turned on, so normal users cannot write. In our test @@read_only was 1 and an INSERT failed until it was set back to OFF.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13