Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8768457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:04:05+00:00 2026-06-13T17:04:05+00:00

ERROR The used command is not allowed with this MySQL version I am having

  • 0

ERROR The used command is not allowed with this MySQL version

I am having problems migrating some mysqlclient C++ code from Mysql 5.1 to 5.5 (using soci). The C++ part is not so relevant – the problem is writing some mysqlclient code which can successfully do a LOAD DATA INFILE on MySQL 5.5.

Here are my notes (LOAD DATA INFILE fails, but normal queries are ok):

  1. The code below works fine on Mysql 5.1, gcc 4.6.1, Oneiric

  2. The same code fails on Mysql 5.5, gcc 4.7.2, Quantal

  3. If I LOAD DATA INFILE from mysql (the command-line client), it works fine (I have updated my.cnf with local-infile=1)

  4. mysql> show variables like ‘%local_infile%’; results in ON

It would be great if there were a SOCI or a configuration solution to this, but if someone has managed to get this to work with libmysqlclient, that would be great to know, too…


#include <soci.h>
#include <mysql/soci-mysql.h>
#include <string>
#include <iostream>

using soci::use;

using namespace std;
using namespace soci;

main()
{
  string val =
    "mysql://"          +
    "host=127.0.0.1"    +
    " dbname=tmp_db"    +
    " user=root"        +
    " password=open_sasame";

    int sum;

    session sql( val );
    sql  << "SELECT 1+1", into( sum );
    cerr << "RESULT=" << sum << endl;     // works fine

    // NEXT LINE FAILS WITH:
    //   The used command is not allowed with this MySQL version
    sql  << "LOAD DATA LOCAL INFILE '/tmp/junk3.txt' INTO TABLE tmp_db.example_tbl FIELDS TERMINATED BY '|' LINES TERMINATED BY '\\n'";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:04:07+00:00Added an answer on June 13, 2026 at 5:04 pm

    The answer is, we need the following line of code:

    mysql_options( &mysql, MYSQL_OPT_LOCAL_INFILE, 0 );
    

    inserted between mysql_init() and mysql_real_connect().

    Below is a snippet of C code for reference. Note that SOCI’s mysql backend can be patched with this line of code for it to work.

    Tested and works on Mysql 5.5, gcc 4.7.2, Quantal.

    #include <mysql.h>
    #include <stdio.h>
    
    main()
    {
      MYSQL mysql;
    
      mysql_init( &mysql );
      mysql_options( &mysql, MYSQL_OPT_LOCAL_INFILE, 0 );
      if ( !mysql_real_connect( &mysql,"127.0.0.1","root","open_sasame","tmp_db",0,NULL,0 ))
      {
        fprintf(stderr, "Failed to connect to database: Error: %s\n",
          mysql_error( &mysql ));
      }
    
      if ( mysql_query( &mysql, "LOAD DATA LOCAL INFILE '/tmp/junk4.txt' "
        "INTO TABLE tmp_db.example_tbl FIELDS TERMINATED BY '|' "
        "LINES TERMINATED BY '\\n'" ))
      {
        fprintf( stderr, "ERROR DURING LOAD DATA LOCAL INFILE\n" );
      }
    
      mysql_close( &mysql );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error when I run the code below. I have normally used
i used `` for column name though im getting error... my code is $sql
i have used impersonation in this application. whenever this error occurs i required to
I am trying to add some error detection to a script that is used
I am getting an error while deploying code for the first time. I used
I have not used PackedArray before, but just started looking at using them from
The compiler gives me the error 'void' type not allowed here...<= operator cannot be
Hello i'm trying to configure apache2 server for python, i used this command to
When installing subversion as a service, I used this command: c:\>svnservice -install --daemon --root
I am trying to cross-compile GCC on Mac OS 10.5.7. I used this command

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.