Take the 2-minute tour ×

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

1 Answer 1

I recommand that you use "LOAD DATA INFILE" Sql Query instead of shell_exec with mysqlimport : http://dev.mysql.com/doc/refman/5.1/en/load-data.html

share|improve this answer

Your Answer


