Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a need in my PHP application (using Zend Framework for what it matters), to import a CSV file into a MySQL database.

I currently do this by using shell_exec() to run a myysqlimport command the imports the file successfully. To make this work, I had to add set-variable=local-infile=1 into my /etc/my.cnf. I have also granted File_priv within MySQL to the user that I run the script as.

However, I understand this may not be secure. What is the correct way to allow mysqlimport to run securely, for only one user?

I'm using MySQL version 5.0.77 on a CentOS Linux server, with PHP 5.2.12.

share|improve this question

I recommand that you use "LOAD DATA INFILE" Sql Query instead of shell_exec with mysqlimport :

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.