Solved

"The used command is not allowed with this MySQL version" on LOAD DATA LOCAL INFILE on a shared server

Posted on 2016-09-01
7
29 Views
Last Modified: 2016-10-22
I use 1&1 shared hosting on which I have a MySQL DB. I needed to load a CSV file into a table on the database and I used the PHP script below to successfully load it yesterday. (variables are all defined in the script but left out for obvious reasons). Today I deleted the data out of the table and tried to run the same script to upload the exact same file and I got the following errer:

"Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1148 The used command is not allowed with this MySQL version' in /homepages/1/d23232323/htdocs/importd.php:32 Stack trace: #0 /homepages/1/d23232323/htdocs/importd.php(32): PDO->exec('? LOAD DATA ...') #1 {main} thrown in /homepages/1/d23232323/htdocs/importd.php on line 32"

Everything I find on the web says I need to change configuration settings in MySQL, the problem is: 1. I don't think I have access to these settings on a shared server and 2. It worked fine yesterday.
Can anyone think of a reason why this would happen all of a sudden and what I could possibly do to remedy it?

if(!file_exists($csvfile)) {
    die("File not found. Make sure you specified the correct path.");
}

try {
    $pdo = new PDO("mysql:host=$databasehost;dbname=$databasename", 
        $databaseusername, $databasepassword,
        array(
            PDO::MYSQL_ATTR_LOCAL_INFILE => true,
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
        )
    );
} catch (PDOException $e) {
    die("database connection failed: ".$e->getMessage());
}

$affectedRows = $pdo->exec("
    LOAD DATA LOCAL INFILE ".$pdo->quote($csvfile)." INTO TABLE `$databasetable`
      FIELDS TERMINATED BY ".$pdo->quote($fieldseparator)."
  OPTIONALLY ENCLOSED BY ".$pdo->quote($fieldenclosed)."
	  LINES TERMINATED BY ".$pdo->quote($lineseparator));

echo "Loaded a total of $affectedRows records from this csv file.\n";

Open in new window

0
Comment
Question by:dannyg280
7 Comments
 
LVL 5

Assisted Solution

by:TechieMD
TechieMD earned 166 total points
ID: 41780271
Grab (apt-get install) the php5-mysqlnd driver, replacing php5-mysql. This is a known bug.
0
 

Author Comment

by:dannyg280
ID: 41780289
TechieMD - Thank you for the reply. I have seen that as a solution however I am on a shared server, If that require command line access to the server than I do not have it. It also seems strange that if that really was the issue, I don't understand why it worked fine yesterday...

Is there a way to replace the driver without command line access?
0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 168 total points
ID: 41780356
It is common practice for ISP's to disable that functionality - they do it on the Linux servers at my ISP but not Windows.

You will need to take it up with them
1
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:dannyg280
ID: 41780456
After an hour on the phone with 1&1 support, the only thing I've been able to confirm is that calling support is a waste of time. He made up about 15 different reasons why it didn't work, most of which were ridiculous....I finally hung up the phone after he decided that the 54 MB file I was importing was actually 55 GB. I repeatedly told him I'm looking at the file on the server and it's 54 MB.

ANyway, when I look at my PHP configuration it appears mysqlnd is installed  - see screenshot.
Screenshot-2016-09-01-14.46.42.jpg
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 166 total points
ID: 41780542
I use and am pleased to recomment ChiHost.  Their tech support "gets it" completely.  I have also had good experiences with HostGator and LiquidHost.  Not so much so with GoDaddy and 1&1, where my support experience has been just like what you've described here.
1
 

Author Comment

by:dannyg280
ID: 41780605
Thanks for the info Ray, I may check them out. Does anyone know why this error message would appear if mysqlnd is indeed installed?
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now