0

I wrote the following code in mysql_workbench which is connected to AWS RDS; I've changed my RDS parametergroup to the proper value and also modified the server connection to have "OPT_LOCAL_INFILE = 1 OPT_LOCAL_OUTFILE= 1l" but still getting error:"prepare s1 from @sql Error Code: 1227. Access denied; you need (at least one of) the FILE privilege(s) for this operation" Not sure if it is related to Prepare statement! Can any one help me out please.

   SET @exec_time =  DATE_FORMAT(NOW(), '%Y%m%d%H%i%s');
   set @sql = concat("
       SELECT  distinct
       ord_disp_dt as 'Date String',
       YEAR(str_to_date(ord_disp_dt,'%m/%d/%Y')) as Year,
       MONTH(str_to_date(ord_disp_dt,'%m/%d/%Y')) as Month,
       Day(str_to_date(ord_disp_dt,'%m/%d/%Y')) as Day,
       Quarter(str_to_date(ord_disp_dt,'%m/%d/%Y')) as Quarter,
       WeekDay(str_to_date(ord_disp_dt,'%m/%d/%Y')) as WeekDay,
       Week(str_to_date(ord_disp_dt,'%m/%d/%Y')) as Week
       FROM dav6100_db_2.t_ord_order
       ORDER BY YEAR,MONTH, DAY
       INTO OUTFILE 'C:/Users/elham/Documents/Uploads/date_dim_",@exec_time,".csv' 
       FIELDS TERMINATED BY '||' 
       ENCLOSED BY '' 
       LINES TERMINATED BY '\r\n' 
       TERMINATED BY '\r\n';"
    );

   prepare s1 from @sql;
   execute s1; 
Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
Elham
  • 9
  • 2
  • It has nothing to do with the prepared statement. It just means that you don't[ have the `FILE` privilege, so it can't use `INTO OUTFILE`. – Barmar Mar 12 '21 at 16:21
  • Depending on how the procedure is defined, either the procedure owner or the caller needs that privilege. – Barmar Mar 12 '21 at 16:22
  • In fact there's no way to use `INTO OUTFILE` on RDS. It won't write to a file on your client host, it will write to a file on the database server host. But you don't have access to that host. – Bill Karwin Mar 12 '21 at 16:23

0 Answers0