How should I tackle --secure-file-priv in MySQL?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







250















I am learning MySQL and tried using a LOAD DATA clause. When I used it as below:



LOAD DATA INFILE "text.txt" INTO table mytable;


I got the following error:




The MySQL server is running with the --secure-file-priv option so it cannot execute this statement




How do I tackle this error?



I have checked another question on the same error message, but still can’t find a solution.



I am using MySQL 5.6










share|improve this question

























  • share path of your csv file

    – Zafar Malik
    Sep 23 '15 at 10:50











  • Of course, you get this error when trying to use mysqldump --tab, as if it wasn't hard enough to get your own data out of mysql.

    – William Entriken
    Mar 9 '17 at 16:19


















250















I am learning MySQL and tried using a LOAD DATA clause. When I used it as below:



LOAD DATA INFILE "text.txt" INTO table mytable;


I got the following error:




The MySQL server is running with the --secure-file-priv option so it cannot execute this statement




How do I tackle this error?



I have checked another question on the same error message, but still can’t find a solution.



I am using MySQL 5.6










share|improve this question

























  • share path of your csv file

    – Zafar Malik
    Sep 23 '15 at 10:50











  • Of course, you get this error when trying to use mysqldump --tab, as if it wasn't hard enough to get your own data out of mysql.

    – William Entriken
    Mar 9 '17 at 16:19














250












250








250


64






I am learning MySQL and tried using a LOAD DATA clause. When I used it as below:



LOAD DATA INFILE "text.txt" INTO table mytable;


I got the following error:




The MySQL server is running with the --secure-file-priv option so it cannot execute this statement




How do I tackle this error?



I have checked another question on the same error message, but still can’t find a solution.



I am using MySQL 5.6










share|improve this question
















I am learning MySQL and tried using a LOAD DATA clause. When I used it as below:



LOAD DATA INFILE "text.txt" INTO table mytable;


I got the following error:




The MySQL server is running with the --secure-file-priv option so it cannot execute this statement




How do I tackle this error?



I have checked another question on the same error message, but still can’t find a solution.



I am using MySQL 5.6







mysql database






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 23 '17 at 12:26









Community

11




11










asked Sep 23 '15 at 10:43









Mohit BhasiMohit Bhasi

3,66542135




3,66542135













  • share path of your csv file

    – Zafar Malik
    Sep 23 '15 at 10:50











  • Of course, you get this error when trying to use mysqldump --tab, as if it wasn't hard enough to get your own data out of mysql.

    – William Entriken
    Mar 9 '17 at 16:19



















  • share path of your csv file

    – Zafar Malik
    Sep 23 '15 at 10:50











  • Of course, you get this error when trying to use mysqldump --tab, as if it wasn't hard enough to get your own data out of mysql.

    – William Entriken
    Mar 9 '17 at 16:19

















share path of your csv file

– Zafar Malik
Sep 23 '15 at 10:50





share path of your csv file

– Zafar Malik
Sep 23 '15 at 10:50













Of course, you get this error when trying to use mysqldump --tab, as if it wasn't hard enough to get your own data out of mysql.

– William Entriken
Mar 9 '17 at 16:19





Of course, you get this error when trying to use mysqldump --tab, as if it wasn't hard enough to get your own data out of mysql.

– William Entriken
Mar 9 '17 at 16:19












12 Answers
12






active

oldest

votes


















340














It's working as intended. Your MySQL server has been started with --secure-file-priv option which basically limits from which directories you can load files using LOAD DATA INFILE.



You may use SHOW VARIABLES LIKE "secure_file_priv"; to see the directory that has been configured.



You have two options:




  1. Move your file to the directory specified by secure-file-priv.

  2. Disable secure-file-priv. This must be removed from startup and cannot be modified dynamically. To do this check your MySQL start up parameters (depending on platform) and my.ini.






share|improve this answer





















  • 2





    By default my.ini can be found from "C:ProgramDataMySQLMySQL Server 5.6" when running MySQL 5.6 on W2012 server. You may also want to check the service startup parameters (e.g. --defaults-file="C:ProgramDataMySQLMySQL Server 5.6my.ini) as they may also list --secure-file-priv itself.

    – vhu
    Sep 23 '15 at 10:59






  • 1





    @Mohitbhasi, my-default.ini should be in the "C:Program FilesMySQLMySQL Server 5.6" folder. The location vhu was referring to is "C:ProgramDataMySQLMySQL Server 5.6". Just in case you haven't noticed.

    – NurShomik
    Jan 16 '16 at 7:20






  • 32





    Value: NULL. FML.

    – William Entriken
    Mar 9 '17 at 16:20






  • 3





    Note that if using "select .. into outfile" you must specify the full path and the full path must match the results of SHOW VARIABLES LIKE "secure_file_priv";

    – TheSatinKnight
    Feb 17 '18 at 17:49






  • 4





    "check the parameters" and "check my.ini" is not a very good answer

    – Roland Seuhs
    Mar 21 '18 at 16:09



















180














I had the same issue. I finally solved using the LOCAL option in the command



LOAD DATA LOCAL INFILE "text.txt" INTO TABLE mytable;



You can find more info here http://dev.mysql.com/doc/refman/5.7/en/load-data.html




If LOCAL is specified, the file is read by the client program on the
client host and sent to the server. The file can be given as a full
path name to specify its exact location. If given as a relative path
name, the name is interpreted relative to the directory in which the
client program was started.







share|improve this answer





















  • 2





    This worked for me and none other. I tried: 1. to upload my txt file in C:ProgramDataMySQLMySQL Server 5.7Uploads, 2. disabling secure_file_priv in my.ini and restarting mysql 3. This one! Thanks :)

    – Kamal Nayan
    Nov 23 '16 at 14:58











  • This worked for me too. I was going to move the files to the secure-fle-priv directory but I didn't have to because this worked perfectly.

    – adg
    Mar 4 '17 at 9:17






  • 7





    I got this error message for MariaDB: "ERROR 1148 (42000): The used command is not allowed with this MariaDB version". The exact version: "mysql Ver 15.1 Distrib 10.1.22-MariaDB, for Linux (x86_64) using readline 5.2"

    – jciloa
    Jul 18 '17 at 11:56






  • 8





    I got "The used command is not allowed with this MySQL version" for mysql version 5.7.19.

    – Alison S
    Oct 5 '17 at 21:14






  • 1





    @AlisonS Try adding the --local-infile flag when running mysql. stackoverflow.com/questions/10762239/…

    – Illya Moskvin
    May 30 '18 at 14:36





















94














On Ubuntu 14 and Mysql 5.5.53 this setting seems to be enabled by default. To disable it you need to add secure-file-priv = "" to your my.cnf file under the mysqld config group. eg:-



[mysqld]
secure-file-priv = ""





share|improve this answer


























  • This worked for me as well. Same version of Ubuntu and MySQL

    – Rodney
    Nov 13 '16 at 14:24






  • 1





    +1 Worked for me. If you are using Ubuntu, don't forget restart mysql service: sudo service mysql restart

    – Emiliano Sangoi
    Jul 20 '17 at 4:07






  • 1





    This is what works if you need it to point to a location that you select per statement where applicable. This works with MySQL 5.7 on Windows Server just as you explained. If you simply comment out the line like # secure-file-priv = ~ then it still has the error since the value shows as NULL doing it this way resolves the problem when you want to pick which directories you can export to on the server, etc.

    – Bitcoin Murderous Maniac
    Mar 5 '18 at 19:06











  • Worked for me with MySQL 5.7 on Windows, whereas the other solutions did not.

    – CGritton
    Dec 3 '18 at 21:47











  • NB: if doing this in Docker you must restart the Docker container.

    – user1717828
    Feb 15 at 14:13



















28














I'm working on MySQL5.7.11 on Debian, the command that worked for me to see the directory is:



mysql> SELECT @@global.secure_file_priv;






share|improve this answer
























  • With SHOW VARIABLES LIKE "secure_file_priv"; I get ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist which is also thrown in other circumstances and I will have to eventually deal with. The SELECT @@global.secure_file_priv; command though produced the expected result.

    – Majid Fouladpour
    Jun 4 '17 at 16:28











  • This worked for me -- Ubuntu Mysql 5.7.21: changed the output file to directory /var/lib/mysql-files/output.txt

    – Shanemeister
    Apr 26 '18 at 17:42











  • How you edit it then? I tried to edit it in /etc/mysql/my.cnf and it seems to have no effect - it stays NULL

    – Slavik
    Mar 14 at 7:32



















15














If the file is local to your machine use the LOCAL in your command



LOAD DATA LOCAL INFILE "text.txt" INTO table mytable;





share|improve this answer































    13














    Here is what worked for me in Windows 7 to disable secure-file-priv (Option #2 from vhu's answer):




    1. Stop the MySQL server service by going into services.msc.

    2. Go to C:ProgramDataMySQLMySQL Server 5.6 (ProgramData was a hidden folder in my case).

    3. Open the my.ini file in Notepad.

    4. Search for 'secure-file-priv'.

    5. Comment the line out by adding '#' at the start of the line. For MySQL Server 5.7.16 and above, commenting won't work. You have to set it to an empty string like this one - secure-file-priv=""

    6. Save the file.

    7. Start the MySQL server service by going into services.msc.






    share|improve this answer





















    • 13





      As of MySQL Server 5.7.16, commenting out the line will not work, because then it will revert to the default, which disables import and export operations. You now need to set it to an empty string if you want to allow these operations from any directory.

      – dbc
      Oct 25 '16 at 14:24






    • 1





      Ramnath, please, edit your answer with @dbc detail for 5.7.x version. Thanks.

      – Rafael Gomes Francisco
      Sep 20 '17 at 20:25











    • Adding an empty string works for me; please change the answer to add an empty string like secure-file-priv=""

      – Rajesh Goel
      Jun 26 '18 at 23:35











    • For Windows make sure to use forward slashes

      – Oliver Oliver
      Mar 31 at 23:16





















    7














    I had the same problem with 'secure-file-priv'. Commenting in the .ini file didn't work and neither did moving file in directory specified by 'secure-file-priv'.



    Finally, as dbc suggested, making 'secure-file-priv' equal to an empty string worked. So if anyone is stuck after trying answers above, hopefully doing this will help.






    share|improve this answer































      3














      I had all sorts of problems with this. I was changing my.cnf and all sorts of crazy things that other versions of this problem tried to show.



      What worked for me:



      The error I was getting



      The MySQL server is running with the --secure-file-priv option so it cannot execute this statement



      I was able to fix it by opening /usr/local/mysql/support-files/mysql.server and changing the following line:



      $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" -- $other_args >/dev/null &
      wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?


      to



      $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --secure-file-priv="" $other_args >/dev/null &
      wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?





      share|improve this answer































        3














        The thing that worked for me:




        1. Put your file inside of the folder specified in secure-file-priv.


        To find that type:




        mysql> show variables like "secure_file_priv";








        1. Check if you have local_infile = 1.


        Do that typing:




        mysql> show variables like "local_infile";




        If you get:



        +---------------+-------+
        | Variable_name | Value |
        +---------------+-------+
        | local_infile | OFF |
        +---------------+-------+


        Then set it to one typing:




        mysql> set global local_infile = 1;








        1. Specify the full path for your file. In my case:



        mysql> load data infile "C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/file.txt" into table test;







        share|improve this answer































          1














          I had this problem on windows 10. "--secure-file-priv in MySQL" To solve this I did the following.




          1. In windows search (bottom left) I typed "powershell".

          2. Right clicked on powershell and ran as admin.

          3. Navigated to the server bin file. (C:Program FilesMySQLMySQL Server 5.6bin);

          4. Typed ./mysqld

          5. Hit "enter"


          The server started up as expected.






          share|improve this answer































            1














            MySQL use this system variable to control where you can import you files



            mysql> SHOW VARIABLES LIKE "secure_file_priv";
            +------------------+-------+
            | Variable_name | Value |
            +------------------+-------+
            | secure_file_priv | NULL |
            +------------------+-------+


            So problem is how to change system variables such as secure_file_priv.




            1. shutdown mysqld

            2. sudo mysqld_safe --secure_file_priv=""


            now you may see like this:



            mysql> SHOW VARIABLES LIKE "secure_file_priv";
            +------------------+-------+
            | Variable_name | Value |
            +------------------+-------+
            | secure_file_priv | |
            +------------------+-------+





            share|improve this answer































              0














              Detailed example on how to check secure_file_priv, grant user and select into outfile yippeecode.com






              share|improve this answer






















                protected by Community Nov 6 '16 at 5:55



                Thank you for your interest in this question.
                Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                Would you like to answer one of these unanswered questions instead?














                12 Answers
                12






                active

                oldest

                votes








                12 Answers
                12






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                340














                It's working as intended. Your MySQL server has been started with --secure-file-priv option which basically limits from which directories you can load files using LOAD DATA INFILE.



                You may use SHOW VARIABLES LIKE "secure_file_priv"; to see the directory that has been configured.



                You have two options:




                1. Move your file to the directory specified by secure-file-priv.

                2. Disable secure-file-priv. This must be removed from startup and cannot be modified dynamically. To do this check your MySQL start up parameters (depending on platform) and my.ini.






                share|improve this answer





















                • 2





                  By default my.ini can be found from "C:ProgramDataMySQLMySQL Server 5.6" when running MySQL 5.6 on W2012 server. You may also want to check the service startup parameters (e.g. --defaults-file="C:ProgramDataMySQLMySQL Server 5.6my.ini) as they may also list --secure-file-priv itself.

                  – vhu
                  Sep 23 '15 at 10:59






                • 1





                  @Mohitbhasi, my-default.ini should be in the "C:Program FilesMySQLMySQL Server 5.6" folder. The location vhu was referring to is "C:ProgramDataMySQLMySQL Server 5.6". Just in case you haven't noticed.

                  – NurShomik
                  Jan 16 '16 at 7:20






                • 32





                  Value: NULL. FML.

                  – William Entriken
                  Mar 9 '17 at 16:20






                • 3





                  Note that if using "select .. into outfile" you must specify the full path and the full path must match the results of SHOW VARIABLES LIKE "secure_file_priv";

                  – TheSatinKnight
                  Feb 17 '18 at 17:49






                • 4





                  "check the parameters" and "check my.ini" is not a very good answer

                  – Roland Seuhs
                  Mar 21 '18 at 16:09
















                340














                It's working as intended. Your MySQL server has been started with --secure-file-priv option which basically limits from which directories you can load files using LOAD DATA INFILE.



                You may use SHOW VARIABLES LIKE "secure_file_priv"; to see the directory that has been configured.



                You have two options:




                1. Move your file to the directory specified by secure-file-priv.

                2. Disable secure-file-priv. This must be removed from startup and cannot be modified dynamically. To do this check your MySQL start up parameters (depending on platform) and my.ini.






                share|improve this answer





















                • 2





                  By default my.ini can be found from "C:ProgramDataMySQLMySQL Server 5.6" when running MySQL 5.6 on W2012 server. You may also want to check the service startup parameters (e.g. --defaults-file="C:ProgramDataMySQLMySQL Server 5.6my.ini) as they may also list --secure-file-priv itself.

                  – vhu
                  Sep 23 '15 at 10:59






                • 1





                  @Mohitbhasi, my-default.ini should be in the "C:Program FilesMySQLMySQL Server 5.6" folder. The location vhu was referring to is "C:ProgramDataMySQLMySQL Server 5.6". Just in case you haven't noticed.

                  – NurShomik
                  Jan 16 '16 at 7:20






                • 32





                  Value: NULL. FML.

                  – William Entriken
                  Mar 9 '17 at 16:20






                • 3





                  Note that if using "select .. into outfile" you must specify the full path and the full path must match the results of SHOW VARIABLES LIKE "secure_file_priv";

                  – TheSatinKnight
                  Feb 17 '18 at 17:49






                • 4





                  "check the parameters" and "check my.ini" is not a very good answer

                  – Roland Seuhs
                  Mar 21 '18 at 16:09














                340












                340








                340







                It's working as intended. Your MySQL server has been started with --secure-file-priv option which basically limits from which directories you can load files using LOAD DATA INFILE.



                You may use SHOW VARIABLES LIKE "secure_file_priv"; to see the directory that has been configured.



                You have two options:




                1. Move your file to the directory specified by secure-file-priv.

                2. Disable secure-file-priv. This must be removed from startup and cannot be modified dynamically. To do this check your MySQL start up parameters (depending on platform) and my.ini.






                share|improve this answer















                It's working as intended. Your MySQL server has been started with --secure-file-priv option which basically limits from which directories you can load files using LOAD DATA INFILE.



                You may use SHOW VARIABLES LIKE "secure_file_priv"; to see the directory that has been configured.



                You have two options:




                1. Move your file to the directory specified by secure-file-priv.

                2. Disable secure-file-priv. This must be removed from startup and cannot be modified dynamically. To do this check your MySQL start up parameters (depending on platform) and my.ini.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Sep 23 '15 at 10:54

























                answered Sep 23 '15 at 10:51









                vhuvhu

                8,035113039




                8,035113039








                • 2





                  By default my.ini can be found from "C:ProgramDataMySQLMySQL Server 5.6" when running MySQL 5.6 on W2012 server. You may also want to check the service startup parameters (e.g. --defaults-file="C:ProgramDataMySQLMySQL Server 5.6my.ini) as they may also list --secure-file-priv itself.

                  – vhu
                  Sep 23 '15 at 10:59






                • 1





                  @Mohitbhasi, my-default.ini should be in the "C:Program FilesMySQLMySQL Server 5.6" folder. The location vhu was referring to is "C:ProgramDataMySQLMySQL Server 5.6". Just in case you haven't noticed.

                  – NurShomik
                  Jan 16 '16 at 7:20






                • 32





                  Value: NULL. FML.

                  – William Entriken
                  Mar 9 '17 at 16:20






                • 3





                  Note that if using "select .. into outfile" you must specify the full path and the full path must match the results of SHOW VARIABLES LIKE "secure_file_priv";

                  – TheSatinKnight
                  Feb 17 '18 at 17:49






                • 4





                  "check the parameters" and "check my.ini" is not a very good answer

                  – Roland Seuhs
                  Mar 21 '18 at 16:09














                • 2





                  By default my.ini can be found from "C:ProgramDataMySQLMySQL Server 5.6" when running MySQL 5.6 on W2012 server. You may also want to check the service startup parameters (e.g. --defaults-file="C:ProgramDataMySQLMySQL Server 5.6my.ini) as they may also list --secure-file-priv itself.

                  – vhu
                  Sep 23 '15 at 10:59






                • 1





                  @Mohitbhasi, my-default.ini should be in the "C:Program FilesMySQLMySQL Server 5.6" folder. The location vhu was referring to is "C:ProgramDataMySQLMySQL Server 5.6". Just in case you haven't noticed.

                  – NurShomik
                  Jan 16 '16 at 7:20






                • 32





                  Value: NULL. FML.

                  – William Entriken
                  Mar 9 '17 at 16:20






                • 3





                  Note that if using "select .. into outfile" you must specify the full path and the full path must match the results of SHOW VARIABLES LIKE "secure_file_priv";

                  – TheSatinKnight
                  Feb 17 '18 at 17:49






                • 4





                  "check the parameters" and "check my.ini" is not a very good answer

                  – Roland Seuhs
                  Mar 21 '18 at 16:09








                2




                2





                By default my.ini can be found from "C:ProgramDataMySQLMySQL Server 5.6" when running MySQL 5.6 on W2012 server. You may also want to check the service startup parameters (e.g. --defaults-file="C:ProgramDataMySQLMySQL Server 5.6my.ini) as they may also list --secure-file-priv itself.

                – vhu
                Sep 23 '15 at 10:59





                By default my.ini can be found from "C:ProgramDataMySQLMySQL Server 5.6" when running MySQL 5.6 on W2012 server. You may also want to check the service startup parameters (e.g. --defaults-file="C:ProgramDataMySQLMySQL Server 5.6my.ini) as they may also list --secure-file-priv itself.

                – vhu
                Sep 23 '15 at 10:59




                1




                1





                @Mohitbhasi, my-default.ini should be in the "C:Program FilesMySQLMySQL Server 5.6" folder. The location vhu was referring to is "C:ProgramDataMySQLMySQL Server 5.6". Just in case you haven't noticed.

                – NurShomik
                Jan 16 '16 at 7:20





                @Mohitbhasi, my-default.ini should be in the "C:Program FilesMySQLMySQL Server 5.6" folder. The location vhu was referring to is "C:ProgramDataMySQLMySQL Server 5.6". Just in case you haven't noticed.

                – NurShomik
                Jan 16 '16 at 7:20




                32




                32





                Value: NULL. FML.

                – William Entriken
                Mar 9 '17 at 16:20





                Value: NULL. FML.

                – William Entriken
                Mar 9 '17 at 16:20




                3




                3





                Note that if using "select .. into outfile" you must specify the full path and the full path must match the results of SHOW VARIABLES LIKE "secure_file_priv";

                – TheSatinKnight
                Feb 17 '18 at 17:49





                Note that if using "select .. into outfile" you must specify the full path and the full path must match the results of SHOW VARIABLES LIKE "secure_file_priv";

                – TheSatinKnight
                Feb 17 '18 at 17:49




                4




                4





                "check the parameters" and "check my.ini" is not a very good answer

                – Roland Seuhs
                Mar 21 '18 at 16:09





                "check the parameters" and "check my.ini" is not a very good answer

                – Roland Seuhs
                Mar 21 '18 at 16:09













                180














                I had the same issue. I finally solved using the LOCAL option in the command



                LOAD DATA LOCAL INFILE "text.txt" INTO TABLE mytable;



                You can find more info here http://dev.mysql.com/doc/refman/5.7/en/load-data.html




                If LOCAL is specified, the file is read by the client program on the
                client host and sent to the server. The file can be given as a full
                path name to specify its exact location. If given as a relative path
                name, the name is interpreted relative to the directory in which the
                client program was started.







                share|improve this answer





















                • 2





                  This worked for me and none other. I tried: 1. to upload my txt file in C:ProgramDataMySQLMySQL Server 5.7Uploads, 2. disabling secure_file_priv in my.ini and restarting mysql 3. This one! Thanks :)

                  – Kamal Nayan
                  Nov 23 '16 at 14:58











                • This worked for me too. I was going to move the files to the secure-fle-priv directory but I didn't have to because this worked perfectly.

                  – adg
                  Mar 4 '17 at 9:17






                • 7





                  I got this error message for MariaDB: "ERROR 1148 (42000): The used command is not allowed with this MariaDB version". The exact version: "mysql Ver 15.1 Distrib 10.1.22-MariaDB, for Linux (x86_64) using readline 5.2"

                  – jciloa
                  Jul 18 '17 at 11:56






                • 8





                  I got "The used command is not allowed with this MySQL version" for mysql version 5.7.19.

                  – Alison S
                  Oct 5 '17 at 21:14






                • 1





                  @AlisonS Try adding the --local-infile flag when running mysql. stackoverflow.com/questions/10762239/…

                  – Illya Moskvin
                  May 30 '18 at 14:36


















                180














                I had the same issue. I finally solved using the LOCAL option in the command



                LOAD DATA LOCAL INFILE "text.txt" INTO TABLE mytable;



                You can find more info here http://dev.mysql.com/doc/refman/5.7/en/load-data.html




                If LOCAL is specified, the file is read by the client program on the
                client host and sent to the server. The file can be given as a full
                path name to specify its exact location. If given as a relative path
                name, the name is interpreted relative to the directory in which the
                client program was started.







                share|improve this answer





















                • 2





                  This worked for me and none other. I tried: 1. to upload my txt file in C:ProgramDataMySQLMySQL Server 5.7Uploads, 2. disabling secure_file_priv in my.ini and restarting mysql 3. This one! Thanks :)

                  – Kamal Nayan
                  Nov 23 '16 at 14:58











                • This worked for me too. I was going to move the files to the secure-fle-priv directory but I didn't have to because this worked perfectly.

                  – adg
                  Mar 4 '17 at 9:17






                • 7





                  I got this error message for MariaDB: "ERROR 1148 (42000): The used command is not allowed with this MariaDB version". The exact version: "mysql Ver 15.1 Distrib 10.1.22-MariaDB, for Linux (x86_64) using readline 5.2"

                  – jciloa
                  Jul 18 '17 at 11:56






                • 8





                  I got "The used command is not allowed with this MySQL version" for mysql version 5.7.19.

                  – Alison S
                  Oct 5 '17 at 21:14






                • 1





                  @AlisonS Try adding the --local-infile flag when running mysql. stackoverflow.com/questions/10762239/…

                  – Illya Moskvin
                  May 30 '18 at 14:36
















                180












                180








                180







                I had the same issue. I finally solved using the LOCAL option in the command



                LOAD DATA LOCAL INFILE "text.txt" INTO TABLE mytable;



                You can find more info here http://dev.mysql.com/doc/refman/5.7/en/load-data.html




                If LOCAL is specified, the file is read by the client program on the
                client host and sent to the server. The file can be given as a full
                path name to specify its exact location. If given as a relative path
                name, the name is interpreted relative to the directory in which the
                client program was started.







                share|improve this answer















                I had the same issue. I finally solved using the LOCAL option in the command



                LOAD DATA LOCAL INFILE "text.txt" INTO TABLE mytable;



                You can find more info here http://dev.mysql.com/doc/refman/5.7/en/load-data.html




                If LOCAL is specified, the file is read by the client program on the
                client host and sent to the server. The file can be given as a full
                path name to specify its exact location. If given as a relative path
                name, the name is interpreted relative to the directory in which the
                client program was started.








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 16 '16 at 11:10

























                answered Nov 16 '16 at 10:54









                StazaStaza

                1,8161711




                1,8161711








                • 2





                  This worked for me and none other. I tried: 1. to upload my txt file in C:ProgramDataMySQLMySQL Server 5.7Uploads, 2. disabling secure_file_priv in my.ini and restarting mysql 3. This one! Thanks :)

                  – Kamal Nayan
                  Nov 23 '16 at 14:58











                • This worked for me too. I was going to move the files to the secure-fle-priv directory but I didn't have to because this worked perfectly.

                  – adg
                  Mar 4 '17 at 9:17






                • 7





                  I got this error message for MariaDB: "ERROR 1148 (42000): The used command is not allowed with this MariaDB version". The exact version: "mysql Ver 15.1 Distrib 10.1.22-MariaDB, for Linux (x86_64) using readline 5.2"

                  – jciloa
                  Jul 18 '17 at 11:56






                • 8





                  I got "The used command is not allowed with this MySQL version" for mysql version 5.7.19.

                  – Alison S
                  Oct 5 '17 at 21:14






                • 1





                  @AlisonS Try adding the --local-infile flag when running mysql. stackoverflow.com/questions/10762239/…

                  – Illya Moskvin
                  May 30 '18 at 14:36
















                • 2





                  This worked for me and none other. I tried: 1. to upload my txt file in C:ProgramDataMySQLMySQL Server 5.7Uploads, 2. disabling secure_file_priv in my.ini and restarting mysql 3. This one! Thanks :)

                  – Kamal Nayan
                  Nov 23 '16 at 14:58











                • This worked for me too. I was going to move the files to the secure-fle-priv directory but I didn't have to because this worked perfectly.

                  – adg
                  Mar 4 '17 at 9:17






                • 7





                  I got this error message for MariaDB: "ERROR 1148 (42000): The used command is not allowed with this MariaDB version". The exact version: "mysql Ver 15.1 Distrib 10.1.22-MariaDB, for Linux (x86_64) using readline 5.2"

                  – jciloa
                  Jul 18 '17 at 11:56






                • 8





                  I got "The used command is not allowed with this MySQL version" for mysql version 5.7.19.

                  – Alison S
                  Oct 5 '17 at 21:14






                • 1





                  @AlisonS Try adding the --local-infile flag when running mysql. stackoverflow.com/questions/10762239/…

                  – Illya Moskvin
                  May 30 '18 at 14:36










                2




                2





                This worked for me and none other. I tried: 1. to upload my txt file in C:ProgramDataMySQLMySQL Server 5.7Uploads, 2. disabling secure_file_priv in my.ini and restarting mysql 3. This one! Thanks :)

                – Kamal Nayan
                Nov 23 '16 at 14:58





                This worked for me and none other. I tried: 1. to upload my txt file in C:ProgramDataMySQLMySQL Server 5.7Uploads, 2. disabling secure_file_priv in my.ini and restarting mysql 3. This one! Thanks :)

                – Kamal Nayan
                Nov 23 '16 at 14:58













                This worked for me too. I was going to move the files to the secure-fle-priv directory but I didn't have to because this worked perfectly.

                – adg
                Mar 4 '17 at 9:17





                This worked for me too. I was going to move the files to the secure-fle-priv directory but I didn't have to because this worked perfectly.

                – adg
                Mar 4 '17 at 9:17




                7




                7





                I got this error message for MariaDB: "ERROR 1148 (42000): The used command is not allowed with this MariaDB version". The exact version: "mysql Ver 15.1 Distrib 10.1.22-MariaDB, for Linux (x86_64) using readline 5.2"

                – jciloa
                Jul 18 '17 at 11:56





                I got this error message for MariaDB: "ERROR 1148 (42000): The used command is not allowed with this MariaDB version". The exact version: "mysql Ver 15.1 Distrib 10.1.22-MariaDB, for Linux (x86_64) using readline 5.2"

                – jciloa
                Jul 18 '17 at 11:56




                8




                8





                I got "The used command is not allowed with this MySQL version" for mysql version 5.7.19.

                – Alison S
                Oct 5 '17 at 21:14





                I got "The used command is not allowed with this MySQL version" for mysql version 5.7.19.

                – Alison S
                Oct 5 '17 at 21:14




                1




                1





                @AlisonS Try adding the --local-infile flag when running mysql. stackoverflow.com/questions/10762239/…

                – Illya Moskvin
                May 30 '18 at 14:36







                @AlisonS Try adding the --local-infile flag when running mysql. stackoverflow.com/questions/10762239/…

                – Illya Moskvin
                May 30 '18 at 14:36













                94














                On Ubuntu 14 and Mysql 5.5.53 this setting seems to be enabled by default. To disable it you need to add secure-file-priv = "" to your my.cnf file under the mysqld config group. eg:-



                [mysqld]
                secure-file-priv = ""





                share|improve this answer


























                • This worked for me as well. Same version of Ubuntu and MySQL

                  – Rodney
                  Nov 13 '16 at 14:24






                • 1





                  +1 Worked for me. If you are using Ubuntu, don't forget restart mysql service: sudo service mysql restart

                  – Emiliano Sangoi
                  Jul 20 '17 at 4:07






                • 1





                  This is what works if you need it to point to a location that you select per statement where applicable. This works with MySQL 5.7 on Windows Server just as you explained. If you simply comment out the line like # secure-file-priv = ~ then it still has the error since the value shows as NULL doing it this way resolves the problem when you want to pick which directories you can export to on the server, etc.

                  – Bitcoin Murderous Maniac
                  Mar 5 '18 at 19:06











                • Worked for me with MySQL 5.7 on Windows, whereas the other solutions did not.

                  – CGritton
                  Dec 3 '18 at 21:47











                • NB: if doing this in Docker you must restart the Docker container.

                  – user1717828
                  Feb 15 at 14:13
















                94














                On Ubuntu 14 and Mysql 5.5.53 this setting seems to be enabled by default. To disable it you need to add secure-file-priv = "" to your my.cnf file under the mysqld config group. eg:-



                [mysqld]
                secure-file-priv = ""





                share|improve this answer


























                • This worked for me as well. Same version of Ubuntu and MySQL

                  – Rodney
                  Nov 13 '16 at 14:24






                • 1





                  +1 Worked for me. If you are using Ubuntu, don't forget restart mysql service: sudo service mysql restart

                  – Emiliano Sangoi
                  Jul 20 '17 at 4:07






                • 1





                  This is what works if you need it to point to a location that you select per statement where applicable. This works with MySQL 5.7 on Windows Server just as you explained. If you simply comment out the line like # secure-file-priv = ~ then it still has the error since the value shows as NULL doing it this way resolves the problem when you want to pick which directories you can export to on the server, etc.

                  – Bitcoin Murderous Maniac
                  Mar 5 '18 at 19:06











                • Worked for me with MySQL 5.7 on Windows, whereas the other solutions did not.

                  – CGritton
                  Dec 3 '18 at 21:47











                • NB: if doing this in Docker you must restart the Docker container.

                  – user1717828
                  Feb 15 at 14:13














                94












                94








                94







                On Ubuntu 14 and Mysql 5.5.53 this setting seems to be enabled by default. To disable it you need to add secure-file-priv = "" to your my.cnf file under the mysqld config group. eg:-



                [mysqld]
                secure-file-priv = ""





                share|improve this answer















                On Ubuntu 14 and Mysql 5.5.53 this setting seems to be enabled by default. To disable it you need to add secure-file-priv = "" to your my.cnf file under the mysqld config group. eg:-



                [mysqld]
                secure-file-priv = ""






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 15 '18 at 4:15

























                answered Nov 4 '16 at 9:49









                MustafaMustafa

                1,95511528




                1,95511528













                • This worked for me as well. Same version of Ubuntu and MySQL

                  – Rodney
                  Nov 13 '16 at 14:24






                • 1





                  +1 Worked for me. If you are using Ubuntu, don't forget restart mysql service: sudo service mysql restart

                  – Emiliano Sangoi
                  Jul 20 '17 at 4:07






                • 1





                  This is what works if you need it to point to a location that you select per statement where applicable. This works with MySQL 5.7 on Windows Server just as you explained. If you simply comment out the line like # secure-file-priv = ~ then it still has the error since the value shows as NULL doing it this way resolves the problem when you want to pick which directories you can export to on the server, etc.

                  – Bitcoin Murderous Maniac
                  Mar 5 '18 at 19:06











                • Worked for me with MySQL 5.7 on Windows, whereas the other solutions did not.

                  – CGritton
                  Dec 3 '18 at 21:47











                • NB: if doing this in Docker you must restart the Docker container.

                  – user1717828
                  Feb 15 at 14:13



















                • This worked for me as well. Same version of Ubuntu and MySQL

                  – Rodney
                  Nov 13 '16 at 14:24






                • 1





                  +1 Worked for me. If you are using Ubuntu, don't forget restart mysql service: sudo service mysql restart

                  – Emiliano Sangoi
                  Jul 20 '17 at 4:07






                • 1





                  This is what works if you need it to point to a location that you select per statement where applicable. This works with MySQL 5.7 on Windows Server just as you explained. If you simply comment out the line like # secure-file-priv = ~ then it still has the error since the value shows as NULL doing it this way resolves the problem when you want to pick which directories you can export to on the server, etc.

                  – Bitcoin Murderous Maniac
                  Mar 5 '18 at 19:06











                • Worked for me with MySQL 5.7 on Windows, whereas the other solutions did not.

                  – CGritton
                  Dec 3 '18 at 21:47











                • NB: if doing this in Docker you must restart the Docker container.

                  – user1717828
                  Feb 15 at 14:13

















                This worked for me as well. Same version of Ubuntu and MySQL

                – Rodney
                Nov 13 '16 at 14:24





                This worked for me as well. Same version of Ubuntu and MySQL

                – Rodney
                Nov 13 '16 at 14:24




                1




                1





                +1 Worked for me. If you are using Ubuntu, don't forget restart mysql service: sudo service mysql restart

                – Emiliano Sangoi
                Jul 20 '17 at 4:07





                +1 Worked for me. If you are using Ubuntu, don't forget restart mysql service: sudo service mysql restart

                – Emiliano Sangoi
                Jul 20 '17 at 4:07




                1




                1





                This is what works if you need it to point to a location that you select per statement where applicable. This works with MySQL 5.7 on Windows Server just as you explained. If you simply comment out the line like # secure-file-priv = ~ then it still has the error since the value shows as NULL doing it this way resolves the problem when you want to pick which directories you can export to on the server, etc.

                – Bitcoin Murderous Maniac
                Mar 5 '18 at 19:06





                This is what works if you need it to point to a location that you select per statement where applicable. This works with MySQL 5.7 on Windows Server just as you explained. If you simply comment out the line like # secure-file-priv = ~ then it still has the error since the value shows as NULL doing it this way resolves the problem when you want to pick which directories you can export to on the server, etc.

                – Bitcoin Murderous Maniac
                Mar 5 '18 at 19:06













                Worked for me with MySQL 5.7 on Windows, whereas the other solutions did not.

                – CGritton
                Dec 3 '18 at 21:47





                Worked for me with MySQL 5.7 on Windows, whereas the other solutions did not.

                – CGritton
                Dec 3 '18 at 21:47













                NB: if doing this in Docker you must restart the Docker container.

                – user1717828
                Feb 15 at 14:13





                NB: if doing this in Docker you must restart the Docker container.

                – user1717828
                Feb 15 at 14:13











                28














                I'm working on MySQL5.7.11 on Debian, the command that worked for me to see the directory is:



                mysql> SELECT @@global.secure_file_priv;






                share|improve this answer
























                • With SHOW VARIABLES LIKE "secure_file_priv"; I get ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist which is also thrown in other circumstances and I will have to eventually deal with. The SELECT @@global.secure_file_priv; command though produced the expected result.

                  – Majid Fouladpour
                  Jun 4 '17 at 16:28











                • This worked for me -- Ubuntu Mysql 5.7.21: changed the output file to directory /var/lib/mysql-files/output.txt

                  – Shanemeister
                  Apr 26 '18 at 17:42











                • How you edit it then? I tried to edit it in /etc/mysql/my.cnf and it seems to have no effect - it stays NULL

                  – Slavik
                  Mar 14 at 7:32
















                28














                I'm working on MySQL5.7.11 on Debian, the command that worked for me to see the directory is:



                mysql> SELECT @@global.secure_file_priv;






                share|improve this answer
























                • With SHOW VARIABLES LIKE "secure_file_priv"; I get ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist which is also thrown in other circumstances and I will have to eventually deal with. The SELECT @@global.secure_file_priv; command though produced the expected result.

                  – Majid Fouladpour
                  Jun 4 '17 at 16:28











                • This worked for me -- Ubuntu Mysql 5.7.21: changed the output file to directory /var/lib/mysql-files/output.txt

                  – Shanemeister
                  Apr 26 '18 at 17:42











                • How you edit it then? I tried to edit it in /etc/mysql/my.cnf and it seems to have no effect - it stays NULL

                  – Slavik
                  Mar 14 at 7:32














                28












                28








                28







                I'm working on MySQL5.7.11 on Debian, the command that worked for me to see the directory is:



                mysql> SELECT @@global.secure_file_priv;






                share|improve this answer













                I'm working on MySQL5.7.11 on Debian, the command that worked for me to see the directory is:



                mysql> SELECT @@global.secure_file_priv;







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 25 '16 at 19:34









                CarlosArturoFyulerCarlosArturoFyuler

                28237




                28237













                • With SHOW VARIABLES LIKE "secure_file_priv"; I get ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist which is also thrown in other circumstances and I will have to eventually deal with. The SELECT @@global.secure_file_priv; command though produced the expected result.

                  – Majid Fouladpour
                  Jun 4 '17 at 16:28











                • This worked for me -- Ubuntu Mysql 5.7.21: changed the output file to directory /var/lib/mysql-files/output.txt

                  – Shanemeister
                  Apr 26 '18 at 17:42











                • How you edit it then? I tried to edit it in /etc/mysql/my.cnf and it seems to have no effect - it stays NULL

                  – Slavik
                  Mar 14 at 7:32



















                • With SHOW VARIABLES LIKE "secure_file_priv"; I get ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist which is also thrown in other circumstances and I will have to eventually deal with. The SELECT @@global.secure_file_priv; command though produced the expected result.

                  – Majid Fouladpour
                  Jun 4 '17 at 16:28











                • This worked for me -- Ubuntu Mysql 5.7.21: changed the output file to directory /var/lib/mysql-files/output.txt

                  – Shanemeister
                  Apr 26 '18 at 17:42











                • How you edit it then? I tried to edit it in /etc/mysql/my.cnf and it seems to have no effect - it stays NULL

                  – Slavik
                  Mar 14 at 7:32

















                With SHOW VARIABLES LIKE "secure_file_priv"; I get ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist which is also thrown in other circumstances and I will have to eventually deal with. The SELECT @@global.secure_file_priv; command though produced the expected result.

                – Majid Fouladpour
                Jun 4 '17 at 16:28





                With SHOW VARIABLES LIKE "secure_file_priv"; I get ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist which is also thrown in other circumstances and I will have to eventually deal with. The SELECT @@global.secure_file_priv; command though produced the expected result.

                – Majid Fouladpour
                Jun 4 '17 at 16:28













                This worked for me -- Ubuntu Mysql 5.7.21: changed the output file to directory /var/lib/mysql-files/output.txt

                – Shanemeister
                Apr 26 '18 at 17:42





                This worked for me -- Ubuntu Mysql 5.7.21: changed the output file to directory /var/lib/mysql-files/output.txt

                – Shanemeister
                Apr 26 '18 at 17:42













                How you edit it then? I tried to edit it in /etc/mysql/my.cnf and it seems to have no effect - it stays NULL

                – Slavik
                Mar 14 at 7:32





                How you edit it then? I tried to edit it in /etc/mysql/my.cnf and it seems to have no effect - it stays NULL

                – Slavik
                Mar 14 at 7:32











                15














                If the file is local to your machine use the LOCAL in your command



                LOAD DATA LOCAL INFILE "text.txt" INTO table mytable;





                share|improve this answer




























                  15














                  If the file is local to your machine use the LOCAL in your command



                  LOAD DATA LOCAL INFILE "text.txt" INTO table mytable;





                  share|improve this answer


























                    15












                    15








                    15







                    If the file is local to your machine use the LOCAL in your command



                    LOAD DATA LOCAL INFILE "text.txt" INTO table mytable;





                    share|improve this answer













                    If the file is local to your machine use the LOCAL in your command



                    LOAD DATA LOCAL INFILE "text.txt" INTO table mytable;






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered May 4 '18 at 14:07









                    garyrgilbertgaryrgilbert

                    24528




                    24528























                        13














                        Here is what worked for me in Windows 7 to disable secure-file-priv (Option #2 from vhu's answer):




                        1. Stop the MySQL server service by going into services.msc.

                        2. Go to C:ProgramDataMySQLMySQL Server 5.6 (ProgramData was a hidden folder in my case).

                        3. Open the my.ini file in Notepad.

                        4. Search for 'secure-file-priv'.

                        5. Comment the line out by adding '#' at the start of the line. For MySQL Server 5.7.16 and above, commenting won't work. You have to set it to an empty string like this one - secure-file-priv=""

                        6. Save the file.

                        7. Start the MySQL server service by going into services.msc.






                        share|improve this answer





















                        • 13





                          As of MySQL Server 5.7.16, commenting out the line will not work, because then it will revert to the default, which disables import and export operations. You now need to set it to an empty string if you want to allow these operations from any directory.

                          – dbc
                          Oct 25 '16 at 14:24






                        • 1





                          Ramnath, please, edit your answer with @dbc detail for 5.7.x version. Thanks.

                          – Rafael Gomes Francisco
                          Sep 20 '17 at 20:25











                        • Adding an empty string works for me; please change the answer to add an empty string like secure-file-priv=""

                          – Rajesh Goel
                          Jun 26 '18 at 23:35











                        • For Windows make sure to use forward slashes

                          – Oliver Oliver
                          Mar 31 at 23:16


















                        13














                        Here is what worked for me in Windows 7 to disable secure-file-priv (Option #2 from vhu's answer):




                        1. Stop the MySQL server service by going into services.msc.

                        2. Go to C:ProgramDataMySQLMySQL Server 5.6 (ProgramData was a hidden folder in my case).

                        3. Open the my.ini file in Notepad.

                        4. Search for 'secure-file-priv'.

                        5. Comment the line out by adding '#' at the start of the line. For MySQL Server 5.7.16 and above, commenting won't work. You have to set it to an empty string like this one - secure-file-priv=""

                        6. Save the file.

                        7. Start the MySQL server service by going into services.msc.






                        share|improve this answer





















                        • 13





                          As of MySQL Server 5.7.16, commenting out the line will not work, because then it will revert to the default, which disables import and export operations. You now need to set it to an empty string if you want to allow these operations from any directory.

                          – dbc
                          Oct 25 '16 at 14:24






                        • 1





                          Ramnath, please, edit your answer with @dbc detail for 5.7.x version. Thanks.

                          – Rafael Gomes Francisco
                          Sep 20 '17 at 20:25











                        • Adding an empty string works for me; please change the answer to add an empty string like secure-file-priv=""

                          – Rajesh Goel
                          Jun 26 '18 at 23:35











                        • For Windows make sure to use forward slashes

                          – Oliver Oliver
                          Mar 31 at 23:16
















                        13












                        13








                        13







                        Here is what worked for me in Windows 7 to disable secure-file-priv (Option #2 from vhu's answer):




                        1. Stop the MySQL server service by going into services.msc.

                        2. Go to C:ProgramDataMySQLMySQL Server 5.6 (ProgramData was a hidden folder in my case).

                        3. Open the my.ini file in Notepad.

                        4. Search for 'secure-file-priv'.

                        5. Comment the line out by adding '#' at the start of the line. For MySQL Server 5.7.16 and above, commenting won't work. You have to set it to an empty string like this one - secure-file-priv=""

                        6. Save the file.

                        7. Start the MySQL server service by going into services.msc.






                        share|improve this answer















                        Here is what worked for me in Windows 7 to disable secure-file-priv (Option #2 from vhu's answer):




                        1. Stop the MySQL server service by going into services.msc.

                        2. Go to C:ProgramDataMySQLMySQL Server 5.6 (ProgramData was a hidden folder in my case).

                        3. Open the my.ini file in Notepad.

                        4. Search for 'secure-file-priv'.

                        5. Comment the line out by adding '#' at the start of the line. For MySQL Server 5.7.16 and above, commenting won't work. You have to set it to an empty string like this one - secure-file-priv=""

                        6. Save the file.

                        7. Start the MySQL server service by going into services.msc.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Apr 4 at 1:15

























                        answered Jun 15 '16 at 13:55









                        RamnathRamnath

                        5251823




                        5251823








                        • 13





                          As of MySQL Server 5.7.16, commenting out the line will not work, because then it will revert to the default, which disables import and export operations. You now need to set it to an empty string if you want to allow these operations from any directory.

                          – dbc
                          Oct 25 '16 at 14:24






                        • 1





                          Ramnath, please, edit your answer with @dbc detail for 5.7.x version. Thanks.

                          – Rafael Gomes Francisco
                          Sep 20 '17 at 20:25











                        • Adding an empty string works for me; please change the answer to add an empty string like secure-file-priv=""

                          – Rajesh Goel
                          Jun 26 '18 at 23:35











                        • For Windows make sure to use forward slashes

                          – Oliver Oliver
                          Mar 31 at 23:16
















                        • 13





                          As of MySQL Server 5.7.16, commenting out the line will not work, because then it will revert to the default, which disables import and export operations. You now need to set it to an empty string if you want to allow these operations from any directory.

                          – dbc
                          Oct 25 '16 at 14:24






                        • 1





                          Ramnath, please, edit your answer with @dbc detail for 5.7.x version. Thanks.

                          – Rafael Gomes Francisco
                          Sep 20 '17 at 20:25











                        • Adding an empty string works for me; please change the answer to add an empty string like secure-file-priv=""

                          – Rajesh Goel
                          Jun 26 '18 at 23:35











                        • For Windows make sure to use forward slashes

                          – Oliver Oliver
                          Mar 31 at 23:16










                        13




                        13





                        As of MySQL Server 5.7.16, commenting out the line will not work, because then it will revert to the default, which disables import and export operations. You now need to set it to an empty string if you want to allow these operations from any directory.

                        – dbc
                        Oct 25 '16 at 14:24





                        As of MySQL Server 5.7.16, commenting out the line will not work, because then it will revert to the default, which disables import and export operations. You now need to set it to an empty string if you want to allow these operations from any directory.

                        – dbc
                        Oct 25 '16 at 14:24




                        1




                        1





                        Ramnath, please, edit your answer with @dbc detail for 5.7.x version. Thanks.

                        – Rafael Gomes Francisco
                        Sep 20 '17 at 20:25





                        Ramnath, please, edit your answer with @dbc detail for 5.7.x version. Thanks.

                        – Rafael Gomes Francisco
                        Sep 20 '17 at 20:25













                        Adding an empty string works for me; please change the answer to add an empty string like secure-file-priv=""

                        – Rajesh Goel
                        Jun 26 '18 at 23:35





                        Adding an empty string works for me; please change the answer to add an empty string like secure-file-priv=""

                        – Rajesh Goel
                        Jun 26 '18 at 23:35













                        For Windows make sure to use forward slashes

                        – Oliver Oliver
                        Mar 31 at 23:16







                        For Windows make sure to use forward slashes

                        – Oliver Oliver
                        Mar 31 at 23:16













                        7














                        I had the same problem with 'secure-file-priv'. Commenting in the .ini file didn't work and neither did moving file in directory specified by 'secure-file-priv'.



                        Finally, as dbc suggested, making 'secure-file-priv' equal to an empty string worked. So if anyone is stuck after trying answers above, hopefully doing this will help.






                        share|improve this answer




























                          7














                          I had the same problem with 'secure-file-priv'. Commenting in the .ini file didn't work and neither did moving file in directory specified by 'secure-file-priv'.



                          Finally, as dbc suggested, making 'secure-file-priv' equal to an empty string worked. So if anyone is stuck after trying answers above, hopefully doing this will help.






                          share|improve this answer


























                            7












                            7








                            7







                            I had the same problem with 'secure-file-priv'. Commenting in the .ini file didn't work and neither did moving file in directory specified by 'secure-file-priv'.



                            Finally, as dbc suggested, making 'secure-file-priv' equal to an empty string worked. So if anyone is stuck after trying answers above, hopefully doing this will help.






                            share|improve this answer













                            I had the same problem with 'secure-file-priv'. Commenting in the .ini file didn't work and neither did moving file in directory specified by 'secure-file-priv'.



                            Finally, as dbc suggested, making 'secure-file-priv' equal to an empty string worked. So if anyone is stuck after trying answers above, hopefully doing this will help.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 2 '16 at 20:59









                            Rsc RscRsc Rsc

                            7114




                            7114























                                3














                                I had all sorts of problems with this. I was changing my.cnf and all sorts of crazy things that other versions of this problem tried to show.



                                What worked for me:



                                The error I was getting



                                The MySQL server is running with the --secure-file-priv option so it cannot execute this statement



                                I was able to fix it by opening /usr/local/mysql/support-files/mysql.server and changing the following line:



                                $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" -- $other_args >/dev/null &
                                wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?


                                to



                                $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --secure-file-priv="" $other_args >/dev/null &
                                wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?





                                share|improve this answer




























                                  3














                                  I had all sorts of problems with this. I was changing my.cnf and all sorts of crazy things that other versions of this problem tried to show.



                                  What worked for me:



                                  The error I was getting



                                  The MySQL server is running with the --secure-file-priv option so it cannot execute this statement



                                  I was able to fix it by opening /usr/local/mysql/support-files/mysql.server and changing the following line:



                                  $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" -- $other_args >/dev/null &
                                  wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?


                                  to



                                  $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --secure-file-priv="" $other_args >/dev/null &
                                  wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?





                                  share|improve this answer


























                                    3












                                    3








                                    3







                                    I had all sorts of problems with this. I was changing my.cnf and all sorts of crazy things that other versions of this problem tried to show.



                                    What worked for me:



                                    The error I was getting



                                    The MySQL server is running with the --secure-file-priv option so it cannot execute this statement



                                    I was able to fix it by opening /usr/local/mysql/support-files/mysql.server and changing the following line:



                                    $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" -- $other_args >/dev/null &
                                    wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?


                                    to



                                    $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --secure-file-priv="" $other_args >/dev/null &
                                    wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?





                                    share|improve this answer













                                    I had all sorts of problems with this. I was changing my.cnf and all sorts of crazy things that other versions of this problem tried to show.



                                    What worked for me:



                                    The error I was getting



                                    The MySQL server is running with the --secure-file-priv option so it cannot execute this statement



                                    I was able to fix it by opening /usr/local/mysql/support-files/mysql.server and changing the following line:



                                    $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" -- $other_args >/dev/null &
                                    wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?


                                    to



                                    $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --secure-file-priv="" $other_args >/dev/null &
                                    wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Dec 1 '16 at 20:54









                                    notthehoffnotthehoff

                                    6091723




                                    6091723























                                        3














                                        The thing that worked for me:




                                        1. Put your file inside of the folder specified in secure-file-priv.


                                        To find that type:




                                        mysql> show variables like "secure_file_priv";








                                        1. Check if you have local_infile = 1.


                                        Do that typing:




                                        mysql> show variables like "local_infile";




                                        If you get:



                                        +---------------+-------+
                                        | Variable_name | Value |
                                        +---------------+-------+
                                        | local_infile | OFF |
                                        +---------------+-------+


                                        Then set it to one typing:




                                        mysql> set global local_infile = 1;








                                        1. Specify the full path for your file. In my case:



                                        mysql> load data infile "C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/file.txt" into table test;







                                        share|improve this answer




























                                          3














                                          The thing that worked for me:




                                          1. Put your file inside of the folder specified in secure-file-priv.


                                          To find that type:




                                          mysql> show variables like "secure_file_priv";








                                          1. Check if you have local_infile = 1.


                                          Do that typing:




                                          mysql> show variables like "local_infile";




                                          If you get:



                                          +---------------+-------+
                                          | Variable_name | Value |
                                          +---------------+-------+
                                          | local_infile | OFF |
                                          +---------------+-------+


                                          Then set it to one typing:




                                          mysql> set global local_infile = 1;








                                          1. Specify the full path for your file. In my case:



                                          mysql> load data infile "C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/file.txt" into table test;







                                          share|improve this answer


























                                            3












                                            3








                                            3







                                            The thing that worked for me:




                                            1. Put your file inside of the folder specified in secure-file-priv.


                                            To find that type:




                                            mysql> show variables like "secure_file_priv";








                                            1. Check if you have local_infile = 1.


                                            Do that typing:




                                            mysql> show variables like "local_infile";




                                            If you get:



                                            +---------------+-------+
                                            | Variable_name | Value |
                                            +---------------+-------+
                                            | local_infile | OFF |
                                            +---------------+-------+


                                            Then set it to one typing:




                                            mysql> set global local_infile = 1;








                                            1. Specify the full path for your file. In my case:



                                            mysql> load data infile "C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/file.txt" into table test;







                                            share|improve this answer













                                            The thing that worked for me:




                                            1. Put your file inside of the folder specified in secure-file-priv.


                                            To find that type:




                                            mysql> show variables like "secure_file_priv";








                                            1. Check if you have local_infile = 1.


                                            Do that typing:




                                            mysql> show variables like "local_infile";




                                            If you get:



                                            +---------------+-------+
                                            | Variable_name | Value |
                                            +---------------+-------+
                                            | local_infile | OFF |
                                            +---------------+-------+


                                            Then set it to one typing:




                                            mysql> set global local_infile = 1;








                                            1. Specify the full path for your file. In my case:



                                            mysql> load data infile "C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/file.txt" into table test;








                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered Dec 30 '18 at 5:31









                                            Vinícius SouzaVinícius Souza

                                            416




                                            416























                                                1














                                                I had this problem on windows 10. "--secure-file-priv in MySQL" To solve this I did the following.




                                                1. In windows search (bottom left) I typed "powershell".

                                                2. Right clicked on powershell and ran as admin.

                                                3. Navigated to the server bin file. (C:Program FilesMySQLMySQL Server 5.6bin);

                                                4. Typed ./mysqld

                                                5. Hit "enter"


                                                The server started up as expected.






                                                share|improve this answer




























                                                  1














                                                  I had this problem on windows 10. "--secure-file-priv in MySQL" To solve this I did the following.




                                                  1. In windows search (bottom left) I typed "powershell".

                                                  2. Right clicked on powershell and ran as admin.

                                                  3. Navigated to the server bin file. (C:Program FilesMySQLMySQL Server 5.6bin);

                                                  4. Typed ./mysqld

                                                  5. Hit "enter"


                                                  The server started up as expected.






                                                  share|improve this answer


























                                                    1












                                                    1








                                                    1







                                                    I had this problem on windows 10. "--secure-file-priv in MySQL" To solve this I did the following.




                                                    1. In windows search (bottom left) I typed "powershell".

                                                    2. Right clicked on powershell and ran as admin.

                                                    3. Navigated to the server bin file. (C:Program FilesMySQLMySQL Server 5.6bin);

                                                    4. Typed ./mysqld

                                                    5. Hit "enter"


                                                    The server started up as expected.






                                                    share|improve this answer













                                                    I had this problem on windows 10. "--secure-file-priv in MySQL" To solve this I did the following.




                                                    1. In windows search (bottom left) I typed "powershell".

                                                    2. Right clicked on powershell and ran as admin.

                                                    3. Navigated to the server bin file. (C:Program FilesMySQLMySQL Server 5.6bin);

                                                    4. Typed ./mysqld

                                                    5. Hit "enter"


                                                    The server started up as expected.







                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered Oct 1 '17 at 22:05









                                                    Jason AllshornJason Allshorn

                                                    1,1331822




                                                    1,1331822























                                                        1














                                                        MySQL use this system variable to control where you can import you files



                                                        mysql> SHOW VARIABLES LIKE "secure_file_priv";
                                                        +------------------+-------+
                                                        | Variable_name | Value |
                                                        +------------------+-------+
                                                        | secure_file_priv | NULL |
                                                        +------------------+-------+


                                                        So problem is how to change system variables such as secure_file_priv.




                                                        1. shutdown mysqld

                                                        2. sudo mysqld_safe --secure_file_priv=""


                                                        now you may see like this:



                                                        mysql> SHOW VARIABLES LIKE "secure_file_priv";
                                                        +------------------+-------+
                                                        | Variable_name | Value |
                                                        +------------------+-------+
                                                        | secure_file_priv | |
                                                        +------------------+-------+





                                                        share|improve this answer




























                                                          1














                                                          MySQL use this system variable to control where you can import you files



                                                          mysql> SHOW VARIABLES LIKE "secure_file_priv";
                                                          +------------------+-------+
                                                          | Variable_name | Value |
                                                          +------------------+-------+
                                                          | secure_file_priv | NULL |
                                                          +------------------+-------+


                                                          So problem is how to change system variables such as secure_file_priv.




                                                          1. shutdown mysqld

                                                          2. sudo mysqld_safe --secure_file_priv=""


                                                          now you may see like this:



                                                          mysql> SHOW VARIABLES LIKE "secure_file_priv";
                                                          +------------------+-------+
                                                          | Variable_name | Value |
                                                          +------------------+-------+
                                                          | secure_file_priv | |
                                                          +------------------+-------+





                                                          share|improve this answer


























                                                            1












                                                            1








                                                            1







                                                            MySQL use this system variable to control where you can import you files



                                                            mysql> SHOW VARIABLES LIKE "secure_file_priv";
                                                            +------------------+-------+
                                                            | Variable_name | Value |
                                                            +------------------+-------+
                                                            | secure_file_priv | NULL |
                                                            +------------------+-------+


                                                            So problem is how to change system variables such as secure_file_priv.




                                                            1. shutdown mysqld

                                                            2. sudo mysqld_safe --secure_file_priv=""


                                                            now you may see like this:



                                                            mysql> SHOW VARIABLES LIKE "secure_file_priv";
                                                            +------------------+-------+
                                                            | Variable_name | Value |
                                                            +------------------+-------+
                                                            | secure_file_priv | |
                                                            +------------------+-------+





                                                            share|improve this answer













                                                            MySQL use this system variable to control where you can import you files



                                                            mysql> SHOW VARIABLES LIKE "secure_file_priv";
                                                            +------------------+-------+
                                                            | Variable_name | Value |
                                                            +------------------+-------+
                                                            | secure_file_priv | NULL |
                                                            +------------------+-------+


                                                            So problem is how to change system variables such as secure_file_priv.




                                                            1. shutdown mysqld

                                                            2. sudo mysqld_safe --secure_file_priv=""


                                                            now you may see like this:



                                                            mysql> SHOW VARIABLES LIKE "secure_file_priv";
                                                            +------------------+-------+
                                                            | Variable_name | Value |
                                                            +------------------+-------+
                                                            | secure_file_priv | |
                                                            +------------------+-------+






                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered Mar 3 at 14:01









                                                            bitfishxyzbitfishxyz

                                                            5151417




                                                            5151417























                                                                0














                                                                Detailed example on how to check secure_file_priv, grant user and select into outfile yippeecode.com






                                                                share|improve this answer




























                                                                  0














                                                                  Detailed example on how to check secure_file_priv, grant user and select into outfile yippeecode.com






                                                                  share|improve this answer


























                                                                    0












                                                                    0








                                                                    0







                                                                    Detailed example on how to check secure_file_priv, grant user and select into outfile yippeecode.com






                                                                    share|improve this answer













                                                                    Detailed example on how to check secure_file_priv, grant user and select into outfile yippeecode.com







                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered Mar 5 at 16:40









                                                                    helloworld2013helloworld2013

                                                                    1,69341323




                                                                    1,69341323

















                                                                        protected by Community Nov 6 '16 at 5:55



                                                                        Thank you for your interest in this question.
                                                                        Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                                                        Would you like to answer one of these unanswered questions instead?



                                                                        這個網誌中的熱門文章

                                                                        Xamarin.form Move up view when keyboard appear

                                                                        Post-Redirect-Get with Spring WebFlux and Thymeleaf

                                                                        Anylogic : not able to use stopDelay()