The examples/tutorial-scramble.lua file has a lot of problems - I think it is out of date with the current mysql-proxy. You'll need some constants and another parameter for the proto.to_response_packet call:
...
local CLIENT_PROTOCOL_41 = 512 -- New 4.1 protocol
local CLIENT_SECURE_CONNECTION = 32768 -- New 4.1 authentication
local MYSQL_AUTH_CAPABILITIES = ( CLIENT_PROTOCOL_41 + CLIENT_SECURE_CONNECTION )
...
proxy.queries:append(1,
proto.to_response_packet({
username = "connect",
response = password.scramble(s.scramble_buffer, password.hash("cpass!1")),
charset = 8, -- default charset
database = c.default_db,
max_packet_size = 1 * 1024 * 1024,
server_capabilities = MYSQL_AUTH_CAPABILITIES
})
)
Thanks due to this GitHub project for the constants - https://github.com/obrun/map-schema/blob/master/map-schema.lua
After this, you'll probably get another error like this:
network_mysqld_proto_password_scramble: assertion `20 == challenge_len' failed
For some reason, the scramble buffer is longer than it should be - if you print it out you'll see nulls at the end - we need to trim it down to 20 chars before we can use it:
...
response = password.scramble((s.scramble_buffer):sub(1,20), password.hash("cpass!1")),
...