How to Fix MySQL Error 1290 (HY000): The --secure-file-priv Issue
Oct 29, 2024 am 10:04 AMError 1290 (HY000): Solving the --secure-file-priv Issue
MySQL error 1290 (HY000), often encountered when attempting to write query results to a text file, is caused by MySQL's --secure-file-priv option. This option restricts the server from writing files to arbitrary locations.
Ubuntu 16.04:
To resolve this issue in Ubuntu 16.04, determine the allowed write directory using the following command:
mysql> SELECT @@GLOBAL.secure_file_priv;
Write to the specified directory as follows:
mysql> SELECT * FROM train INTO OUTFILE '/var/lib/mysql-files/test.csv' FIELDS TERMINATED BY ',';
Mac OSX (MAMP Installation):
- Check the allowed write directory:
mysql> SELECT @@GLOBAL.secure_file_priv;
If the result is NULL, create a file named '~/.my.cnf' and add the following lines:
[mysqld_safe] [mysqld] secure_file_priv="/Users/username/"
- Replace 'username' with your user directory.
- Restart the MySQL server via MAMP.
- Verify the change:
mysql> SELECT @@GLOBAL.secure_file_priv;
- Export the table:
mysql> SELECT * FROM train INTO OUTFILE '/Users/username/test.csv' FIELDS TERMINATED BY ',';
By following these steps, you can disable the --secure-file-priv restriction and write query results to specified text files on your system.
The above is the detailed content of How to Fix MySQL Error 1290 (HY000): The --secure-file-priv Issue. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Reduce the use of MySQL memory in Docker

How do you alter a table in MySQL using the ALTER TABLE statement?

How to solve the problem of mysql cannot open shared library

What is SQLite? Comprehensive overview

Run MySQl in Linux (with/without podman container with phpmyadmin)

Running multiple MySQL versions on MacOS: A step-by-step guide

How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)?

How do I configure SSL/TLS encryption for MySQL connections?
