2

I know there are many mysql-proxy questions on SO, however I have read through many of them and none seem to solve my problem. I am simply trying to get mysql-proxy up and running, with the eventual purpose of rewriting some queries that go through the proxy. I am using ubuntu 14.04, I have mysql-proxy version 0.8.1, and mysql version 5.5.37. To start mysql-proxy I run the following line on the command line

sudo mysql-proxy --defaults-file=mysql-proxy.cnf

where the file mysql-proxy.cnf looks like the following:

[mysql-proxy]
log-file=                   /var/log/mysql/proxy-error.log
log-level=                  debug
admin-lua-script=           /usr/lib/mysql-proxy/lua/admin.lua
proxy-lua-script=       /path/to/lua/script/example.lua
admin-username =            myusername
admin-password =            mypassword
proxy-skip-profiling =      true
proxy-address =             localhost:4040
proxy-backend-addresses =   localhost:3306
plugins =                   proxy,admin

My example.lua script is very simple, and meant only to verify that the mysql-proxy query is being altered. example.lua is pasted below

-- first_example.lua
function read_query(packet)
    if string.byte(packet) == proxy.COM_QUERY then
        print("Hello world! Seen the query: " .. string.sub(packet, 2))
    end
end

Since I don't run this with the --daemon flag, when I run that line above in the command line it just loops indefinitely, which is expected.

Finally, in separate terminal session, I run the following on the command line and enter my password in order to connect with the proxy

mysql -u myusername -p -h localhost -P 4040

I then select a database to use, and run a simple SELECT query on one of the tables. Based on multiple articles/tutorials I've read on mysql-proxy, my first console session, the one that ran mysql-proxy, should print out some data based on the example.lua file. However this does not happen, in fact nothing happens.

I'm not sure if the following bit of information makes any difference, but in my "my.cnf" mysql configuration file, I have these couple of lines

bind-address            = 255.255.255.255
#bind-address           = 127.0.0.1

where I have replaced my actual ip address with 255.255.255.255 because I do not want to display my ip address publicly.

Please, I have been trying to figure this out for several days, and no amount of new lua scripts, or changing the host:port parameters in the mysql-proxy.cnf file have solved anything. I

4

0 回答 0