Alright, this is a hopeful fix here. I can't test it because I'm on a Nokia phone at the moment.
You're going to have to download, unpack, modify and then make the luasql-mysql rock.
Navigate your way to some temporary place and download the luasql rock:
1
2
$ cd ~; mkdir tmp; cd tmp
$ luarocks-5.1 download luasql-mysql
Then unpack the rock and move it's rockspec into the luasql directory:
1
2
3
4
$ luarocks-5.1 unpack luasql-mysql-2.3.0-1.src.rock
$ cd luasql-mysql-2.3.0-1
$ mv luasql-mysql-2.3.0-1.rockspec luasql/
$ cd luasql
Now, edit the luasql-mysql-2.3.0-1.rockspec file. Change this:
1
2
3
4
5
6
7
8
9
10
11
build = {
	type = "builtin",
	modules = {
		["luasql.mysql"] = {
			sources = { "src/luasql.c", "src/ls_mysql.c" },
			libraries = { "mysqlclient" },
			incdirs = { "$(MYSQL_INCDIR)" },
			libdirs = { "$(MYSQL_LIBDIR)" }
		}
	}
}
To this:
1
2
3
4
5
6
7
8
9
10
11
build = {
	type = "builtin",
	modules = {
		["luasql.mysql"] = {
			sources = { "src/luasql.c", "src/ls_mysql.c" },
			libraries = { "mysqlclient", "lua5.1" },
			incdirs = { "$(MYSQL_INCDIR)" },
			libdirs = { "$(MYSQL_LIBDIR)" }
		}
	}
}
( add "lua5.1" to the libraries table )
Then you need to make the rock:
1
$ luarocks-5.1 make luasql-mysql-2.3.0-1.rockspec
If you get "Could not find expected file mysql.h", you'll want to do:
1
$ luarocks-5.1 make luasql-mysql-2.3.0-1.rockspec MYSQL_INCDIR=/usr/include/mysql
The luarocks make command needs to be run as root.
Hopefully that will fix your problem.