0

I need to export data from mysql to a csv file with column heading but i dont have file permission on the server. Is there any otherway to do it? i.e. using php fwrite? or fputcsv?

Any help will be much appriciate.

Thanks.

2
  • fputcsv was made for it so... yeah... erm.... use that Commented Oct 1, 2010 at 0:35
  • Hi thanks, Is it possible to give detail example? I am not expert on this things. Thanks in advance. Commented Oct 1, 2010 at 14:42

1 Answer 1

0

If you can connect to the MySQL server, you can run the mysqldump utility, which is capable of generating CSV files. This is far easier than trying to come up with something yourself.

mysqldump --tab --fields-terminated-by="," --host=$SERVER --user=$USERNAME --password=$PASSWORD $DATABASE
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for quick response mr Michael Mior where it will save the file? Is there a way to specify a file name for output?
The file will get written to standard output. If you want to save to a file, just redirect by adding ` > filename` to the end.
It is specifically stated that the user doesn't have FILE permission on the mysql server. mysqldump --tab option uses SELECT INTO OUTFILE which requires this permission. This answer therefore will not work in the given situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.