mysqldatabasesqlyog

MYSQL Error Code: 1290 - The MySQL server is running with the --secure-file-priv option so it cannot execute this statement


I'm following the instructions in this video to try and build a retrosheet SQL database, and I'm having issues executing the SQL script to do a bulk insert into the database.

I was previously able to do this with MYSQL 5.7, but recently upgrade to 8.0 and I'm now getting stuck at this step. I've tried following the advice in the video to comment out the --secure-file-priv option in the my.ini file, and I've also tried setting it to the directory location of the data I want to import, but in both situations I'm still getting the error message "Error Code: 1290 - The MySQL server is running with the --secure-file-priv option so it cannot execute this statement."

I've also run this SHOW VARIABLES LIKE 'secure_file_priv'; command in SQLYOG to verify that the secure_file_priv option has been updated.

Has anything changed between mysql versions that this method no long works to turn of the --secure-file-priv option?

Video I'm watching for reference: https://www.youtube.com/watch?v=P9S8bYt9JZY

EDIT:

Variable_name Value
secure_file_priv NULL

Full error message:

Error occured at:2018-01-14 13:47:23 Line no.:1 Error Code: 1290 - The MySQL server is running with the --secure-file-priv option so it cannot execute this statement


Solution

  • Tested on MySQL 8.0.29 on Windows 11.

    On my.ini be sure to have

    # Secure File Priv.
    secure-file-priv="C:/ProgramData/MySQL/MySQL Server 8.0/Uploads"
    

    or another path.

    Then create your file and upload it to the above path.

    I created the test.txt file with some data and upload in the Uploads folder as below image.

    enter image description here

    Then I created a test table.

    create table test (
    id int );
    

    Used the load data command

    LOAD DATA INFILE 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/test.txt' INTO TABLE test
    LINES TERMINATED BY '\r\n'; 
    

    And everything works fine.

    select * from test;
    

    enter image description here