MySQL – Import CSV Data from Localhost Emacs SQLi Error

csvMySQL

I'm trying to import

LOAD DATA LOCAL INFILE "/home/frederic/cowtest.csv"
    INTO TABLE cow_db1 FIELDS TERMINATED BY ","
    ENCLOSED BY '"' LINES TERMINATED BY '\n'
    IGNORE 1 LINES (state_abb, c_code, state_name);

I get: ERROR 1148 (42000): The used command is not allowed with this MySQL version

I connected mysql with M-x sql-mysql and

User = root
Password = …..
Database =
Server = localhost

But running directly from the shell after

mysql -h localhost -u root -p --local-infile

does not return the error but

Query OK, 243 rows affected (0.05 sec)
Records: 243  Deleted: 0  Skipped: 0  Warnings: 0

I tried with LOAD DATA LOCAL INFILE instead (has recommended in other solution) and then it returns ERROR 29 (HY000): File '/home/frederic/cowtest.csv' not found (Errcode: 13)

So it is likely that things goes unspecified about SQLi extension, and the --local-infile specification.

Many thanks
frederic

Best Answer

It seems variable "local_infile" is turned off before loading and if you specify "--local-infile" turns on this variable.

You can use following steps to load file

login mysql using mysql -uroot -p
set global local_infile to value 1
Then try load data local infile

Hope it helps