Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to upload a csv file into my mysql database from php code. I am getting an error: "Could not updated:The used command is not allowed with this MySQL version"

This is the code I am using. Do i have to give any kinds of permissions so that I am able to do it from php forms.? As I am able to load this same csv file from mysql directly from terminal.

P.S.:- I have changed my.cnf file after reading this post. enable LOAD DATA LOCAL INFILE

How ever i am unable to upload from phpmyadmin and from php forms. Error Message is same. i.e. "Could not updated:The used command is not allowed with this MySQL version"

Below is the piece of code.

if(@$_POST['submit'])
{
    $file = $_FILES['file'];
    $name = $file['name'];
    $type = $file['type'];
    $size = $file['size'];
    $tmppath = $file['tmp_name']; 
    echo "Name of the file is $name <br> $tmppath";
    if($name!="")
    {
        echo "<br> Trying to upload file <br>";         
        if(move_uploaded_file($tmppath, "csvfiles/.$name")) //project is a folder in which you will save csv files
        {
            $query="LOAD DATA LOCAL INFILE '$tmppath' INTO TABLE test.metadata FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;";
            mysql_query ($query) or die ('Could not updated:'.mysql_error());
            echo "CSV file inserted successfully !!<br>";
        }else {echo "<br>Failed !!!!";}
    }else {echo "<br>No file exist <br>";}
}else {echo " <br> No file exist <br>";}
share|improve this question
The version of MySQL you are using seems an appropriate thing to include. – leftclickben May 27 at 9:55
Its MySql 5.5, latest one I could get from apt-get install command. – Ameya May 27 at 9:58

1 Answer

If LOAD DATA LOCAL is disabled, either in the server or the client, a client that attempts to issue such a statement receives the following error message:

ERROR 1148: The used command is not allowed with this MySQL version

Try to run below in if UNIX

mysql_fix_privilege_tables --password=root_password

or if windows

C:\> cd "C:\Program Files\MySQL\MySQL Server 5.0"
C:\> bin\mysql -u root -p mysql
mysql> SOURCE share/mysql_fix_privilege_tables.sql
share|improve this answer
I am using ubuntu 12.4 and when I run mysql_fix_privilege_tables --password=root_password it gives me error command not found. – Ameya May 27 at 10:27
Can you run mysql_upgrade – Yogus May 27 at 10:49
I got this error. Could not create the upgrade info file '/var/lib/mysql/mysql_upgrade_info' in the MySQL Servers datadir, errno: 13 – Ameya May 27 at 11:33
I did it using superuser, It is upgraded now. – Ameya May 27 at 11:36
Nope, the upgrade did not work, I guess coz I am getting the same error when i try to load the file from php form. – Ameya May 27 at 11:46
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.