Hello all,
i have a drupal site that tried to load a user uploaded file into the database using the "LOAD DATA LOCAL INFILE" command. after migrating to a new server that has:
mysql Ver 14.14 Distrib 5.5.32, for debian-linux-gnu (i686) using readline 6.2

i get the following error when trying to execute the code: " The used command is not allowed with this MySQL version: LOAD DATA LOCAL INFILE "

i did some research and it seems there are two viable solutions:
1- recompile mysql with the load-infile option enabled (not possible in my case"
2- modify the connection settings to add "mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, true);" as per the following post: http://ubuntuforums.org/showthread.php?t=1970615

i found in the drupal 7 changelog that connection options settings have been modified to allow users to add options in settings.php but i cannot find any examples on how to specify connection options in settings.php

any suggestion would help greatly.
thank you

Comments

John_B’s picture

The main documentation, is (as usual with Drupal) in a note about this in the comment text added to the code, in this case in Drupal's settings.php starting at line 166.

It is PDO not mysqli options you need for Drupal 7.

There is a discussion including an example of an array setting up database connection (not for Drupal, but similar) here http://stackoverflow.com/questions/10762239/enable-load-data-local-infile

Not guaranteed to work though. I would try changing my.cnf (as discussed in linked post) to see if that fixes it. If you cannot, you may need to move to a server which supports the setup you need.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

rfay’s picture

Here's how you add to the db connection array:

  'pdo' => array(PDO::MYSQL_ATTR_LOCAL_INFILE =>1),

as in

$databases['default']['default'] = array (
  'database' => 'd8dev',
  'username' => 'root',
  'password' => '',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
  'pdo' => array(PDO::MYSQL_ATTR_LOCAL_INFILE => 1 ),
);