How to overwrite the existing CSV file with new file while export from MYSQL -
i have export mysql table info csv file every 5 minutes same file location , file name. run next query export:
select * outfile ' c:/newfolder/matrix.csv ' fields terminated ',' lines terminated '\n' tablename
when export data, first time exported correctly, sec time shows error "sql error(1086) file:' c:/newfolder/matrix.csv ' exists". need overwrite existing file.
can 1 help solve problem?
i guess using select ... outfile
statement.
according documentation file cannot exists or statement fail:
the select ... outfile 'file_name' form of select writes selected rows file. file created on server host, must have file privilege utilize syntax. file_name cannot existing file...
use file mysqldump instead , set in crontab
*/5 * * * * /path/to/your/file/backup.sh
mysql csv
No comments:
Post a Comment