0

I am trying to download the million of records from the database using OUTFILE. I am getting this error Error Number: 1290

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

SELECT name, cp_id FROM campaign INTO OUTFILE '/var/www/html/test_csv/1184445179_180912015611.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY ' ';

Filename: models/Admin_model.php

Line Number: 976

below is the model code:

$pth = rand().'_'.date('ymdhis').'.'.'csv'; $path = $_SERVER['DOCUMENT_ROOT'].'/test_csv/'.$pth; $ad = $this->db->query("SELECT name, cp_id FROM campaign INTO OUTFILE '$path' FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n';")

  • Since mysql is running with --secure-file-priv can't you use codeigniter function to output csv from a query result? https://www.codeigniter.com/userguide3/database/utilities.html#export-a-query-result-as-a-csv-file – marcogmonteiro Sep 12 '18 at 20:00
  • yes i am using codeigniter – Amit Gupta Sep 13 '18 at 06:37
  • Them try the built in tool and see if you get any difference. Otherwise I think you have to enable OUTFILE in your server. For that you can see this thread here: https://stackoverflow.com/questions/6091427/mysql-into-outfile-access-denied-but-my-user-has-all-access-and-the-fold – marcogmonteiro Sep 13 '18 at 13:53
  • Ok, let me try to connect to the server using putty file and run the below command, if it works, i will reply you what is going wrong or not... Thanks.. – Amit Gupta Sep 14 '18 at 06:08
  • i will run the below comman: - grant all privileges on YOUR_DATABASE.* to 'asdfsdf'@'localhost' identified by 'your_password'; > flush privileges; – Amit Gupta Sep 14 '18 at 06:08

0 Answers0