0

I am having some problems getting this one sorted...

I am trying to import a CSV file into the database via a PHP script run with cron. I am getting the error "Syntax error or access violation: 1148 The used command is not allowed with this MySQL version". The import is done with PDO:

$this->database = new \PDO("mysql:host=".dbHost.";dbname=".dbTable, dbUserName, dbPassword, array(\PDO::MYSQL_ATTR_LOCAL_INFILE => TRUE));

$this->controller->putIntoDatabase("LOAD DATA LOCAL INFILE '".ftpPriceFileDestTXT."' INTO TABLE my_table FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n'");

As you can see, I have supplied the LOCAL_INFILE attribute. I have also added local-infile=1 to my.cnf under [client] and [mysqld] sections. All php.ini files (in directories /etc/php5/apache2, cgi and cli) contain mysqli.allow_local_infile = On under [MySQL] and [MySQLi] and are all uncommented.

If try in phpmyadmin, everything works fine with no errors and the full content of the file are imported. I just can't seem to get it working via cron (or via shell_exec). The argument given to both cron and the shell_exec function is

/usr/bin/php /home/full/path/to/my/script/cron.php suppliedArgument 

I am running Ubuntu server 14.04 on a VPS box

I'm sure I must be missing something but don't know what, does anybody have any advice or suggestions for tackling this?

Tom
  • 13
  • 3
  • possible duplicate of [Error 1148 MySQL The used command is not allowed with this MySQL version](http://stackoverflow.com/questions/12819098/error-1148-mysql-the-used-command-is-not-allowed-with-this-mysql-version) – Jens Oct 06 '14 at 11:11
  • Have tried all proposed solutions in that thread to no avail – Tom Oct 06 '14 at 11:17
  • This is a already answered question. You can See the solution [here][1] [1]: http://stackoverflow.com/questions/12819098/error-1148-mysql-the-used-command-is-not-allowed-with-this-mysql-version – Param Kumar Oct 06 '14 at 11:20
  • It may be answered for those guys, but as I stated in the original question, after trying all of the above, my problem still persists – Tom Oct 06 '14 at 11:25

1 Answers1

0

Simple solution: create a blank PHP file for the CRON job and call the above script via CURL or file_get_contents (just like you'd call it from the browser). This will help you to avoid dependency issues

George Sharvadze
  • 560
  • 9
  • 25
  • Just tried that, unfortunately I'm getting the same error when run from any php script. Any idea's why it works with phpmyadmin? – Tom Oct 06 '14 at 12:40