I have to automatically generate a csv file of database tables from mariadb server to a linux server. Using maraidb 10.2.33
I created an event in mariadb but I could not find any files generated in the linux server.
my code:
CREATE EVENT `automatic_export_computers`
ON SCHEDULE EVERY 1 DAY_HOUR STARTS '2022-01-24 15:15:00'
ON COMPLETION PRESERVE
ENABLE
COMMENT 'Save Table to CSV for Excel'
Do SELECT * FROM `glpi`.`glpi_computers`
INTO OUTFILE '/data_computers2.csv'
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';
so is there any script using I can generate csv file.
plz help!
Thank you!
Make sure that the event scheduler is enabled. If not, enable it with set global_event_scheduler=ON
or add the option to your configuration file.
Make sure that the user under which MariaDB is running, has permissions to write to the specified location. In your example writing to /data_computers2.csv
will require that MariaDB server is running as root (you can specify ./data_computer2.csv
so the file will be written to the data directory of MariaDB server).
Open the error log and check why the event wasn't executed successfully.