In the next proxy release we introduce plugins, we talked about it already in MySQL Proxy: a chassis and a mysql server. Take a look at and check out:

  • proxy
  • admin
  • debug

each of them sharing the common code that is provided by the chassis.

The debug plugin is a lua shell with a mysql-protocol ... well, just read on ;)

The purpose of the plugin is to be able to introspect the proxy at runtime. If it is loaded you can connect to port 4043 and execute lua code inside the proxy core:

$ mysql --user=root --password=secret --port=4043 --host=
root@ [(none)]> return 1;
| lua  |
| 1    |
1 row in set (0.03 sec)

On the command-line this looks to the same:

 $ echo "return 2" | \
    mysql --user=root --password=secret --port=4043 --host=

You can also let lua load and execute a file:

$ echo "return assert(loadfile('dump-backends.lua'))()" | \
    mysql --user=root --password=secret --port=4043 --host=
ERROR 1105 (07000) at line 1: [string "return assert(loadfile('dump-backends.lua')..."]:1: cannot open dump-backends.lua: No such file or directory

Perhaps we should first create the file:

local res = { }

for i = 1, do
    local b =[i]

    res[#res + 1] = {
            address = b.address,
            state   = b.state,
            type    = b.type

return res

... and execute the script again:

$ echo "return assert(loadfile('dump-backends.lua'))()" | \
    mysql --user=root --password=secret --port=4043 --host=
state   type    address
0       1

As the debug plugin and the proxy plugin share the same lua-scope you can tweak and change parameters in the proxy at runtime. Use it with care.


Enable javascript to load comments.