0

I am connecting to a mysql database from lua using :

mysql = require "luasql.mysql"
local env = mysql.mysql()
local conn = env:connect(database,userName,password)

but the option local-infile is not activated so my requests using LOAD DATA don't work. I tried to put the line

local-infile = 1

in the file my.cnf in the field [client] but it still doesn't work. FYI : I am using linux and mysql 5.1.

Vin
  • 10,517
  • 10
  • 58
  • 71
guadoc
  • 1
  • 2

1 Answers1

1

I went through the same situation last week. The query LOAD DATA INFILE worked on Mac OSX, but I could not make it work on Ubuntu. The only way I found to make it work was adding one line of code to the LuaSQL project and recompiling it.

I used the MySQL driver's function mysql_options (you can check its prototype in the mysql.h file, probably located at /usr/include/mysql) to enable the local-infile. You can check the code at the repository.

To compile and install this workaround, you should download the files:

$ wget https://github.com/rafaeldias/luasql/archive/master.zip
$ unzip master.zip

To compile and install :

$ cd luasql-master/
$ make
$ sudo make install

Note: Depending on where your Lua and MySQL folders are located, you may need to set the proper values for the LUA_LIBDIR, LUA_DIR , LUA_INC , DRIVER_LIBS and DRIVER_INCS in the config file within the LuaSQL folder.

Hope it helps.

Community
  • 1
  • 1
rdleal
  • 987
  • 5
  • 15