I’ve seen some interest in trying to get LuaSocket working with MySQL Proxy, and most of those interested have run into issues getting this set up, so I want to provide a brief walk-through on how to get this set-up and working properly.
Note I tested this on Windows, so use .so instead of .dll on *nix systems.
1. Download LuaSocket (contains lua/ and lib/ directories)
2. Copy contents of ‘lua/’ into the following directory:
3. Copy contents of ‘lib/’ into the following directory:
4. In step #3, you should have copied a ‘socket/’ and ‘mime/’ directories into bin/. Rename the directory named “socket” to “lua-socket”. This will get you past one set of errors.
5. Next, in the C:Program FilesMySQLmysql-proxy-0.8.0bin, there is a file named lua51.dll. If you try to run it now, you’ll get an error saying “lua5.1.dll was not found”. So make a *copy* of “lua51.dll” and rename it “lua5.1.dll” (in the same directory).
6. Invoke your proxy script with the correct –lua-cpath and –lua-path options (below is correct relative to my basedir and with regards to where I copied the contents of the LuaSocket):
C:Program FilesMySQLmysql-proxy-0.8.0bin>mysql-proxy.exe --proxy-lua-script=show-vars.lua --lua-cpath=!\lua-?.dll --lua-path=!\..\lib\mysql-proxy\lua\?.lua;!\..\lib\mysql-proxy\lua\socket\?.lua
Proxy should start up fine with the script, it works, and you can access the socket functions within your own lua script.
For instance, my proxy basedir, which is also where my script is located, is:
show-vars.lua is the name of my lua script.
In it, I have the following 2 lines:
socket = require("socket") print(socket._VERSION)
And when I start up the script, and connect to my instance, it outputs the following: