Wednesday, October 3, 2012

MySQL outfile write permission

When unloading data from MySQL database, it is needed to given special WRITE permission for user to write files.

Refer below command.

SQL command for unload data

  • select * into outfile '/tmp/testfile.txt' fields terminated by '|' from recharge where req_date<'2012-10-03';

SQL command to grant write permission

  • GRANT FILE ON *.* TO 'sujith'@'localhost';
  • flush privileges;