I want to export data from mysql quickly to an output file. As it turns out, INTO OUTFILE syntax seems miles ahead of any kind of processing I can do in PHP performance wise . However, this aproach seems to be ridden with problems:
- The output file can only be created in /tmp or /var/lib/mysql/ (mysqld user needs write permissions)
- The output file owner and group will be set as mysqld
- tmp dir is pretty much a dumpster fire because of settings like "private tmp".
How would I manage this in a way that isn't a nightmare in terms of managing the user accounts / file permissions? I need to access the output file from my php script and I would also like to output this file to the application directory if possible. Of course, if there is another way to export my query results in a performance effective way, I would like to know of it.
Currently I am thinking of the following aproaches:
- Add mysqld user to a "www-data" group to give access to application files, write to application dir and other www-data users will hopefully be able to access the output files.