Grant FILE to MySQL user?

software development


I’m trying to execute a LOAD DATA command on my Rails database. It fails with an ‘access denied’ error regardless of how I execute the command (Rails db:migrate, phpMyAdmin, mysql command line). From reading around, it looks like my user doesn’t have FILE privileges. I can’t seem to grant those to my user; how do I get those privileges?
Alternatively, if I’m attempting something stupid, how should I be going about this? This seems like a pretty typical thing to want to do for a Rails application, but then I’m new at the game. Any suggestions, please?


Well, outside of the permission settings allowed in the control panel, there isn’t any way to grant yourself additional permissions on the database, so you’re probably out of luck trying to use the LOAD DATA command directly.

What format is your data file in? If it’s a bunch of SQL, you can load the file in from the shell by executing mysql -h -uuser -ppassword < data.sql If the file is some other type of structured file (CSV, tab delimited, etc.), then what you should probably do is write a parser by hand using whatever language you feel most comfortable with and use its database interface to create and execute a bunch of INSERT queries for you.


The data is in fact a CSV file. I 'm a bit puzzled that the LOAD DATA command isn’t supported. Is it a security problem or something? It sure seems like people would want to use it rather than writing their own parsers!
Thanks for your response, I’m off to evaluate my options.


This page has at least a brief outline of the security implications of the LOAD DATA commands. Looks like there are some potential vulnerabilities there which would be things that any shared host would be wise to stay away from.

Best of luck with the alternative solution!