Setting up mysql proxy (windows)

Sometimes you need to view the exact query that your client sent to the server. For example, if you don’t know how PDO binds and escapes params or you’re using ORM. There is mysql proxy utility to facilitate this. So in order to install it you should:

1. Download the distribution fromĀ …
2. You don’t need to install anything. Just launch

C:\downloads\mysql-proxy-0.8.0-win32-x86\bin>mysql-proxy.exe --proxy-backend-addresses=localhost:3306 --proxy-lua-script=c:\downloads\mysql-proxy-0.8.0-win32-x86\share\doc\mysql-proxy\tutorial-query-time.lua

where ‘proxy-backend-addresses’ is the IP:port where to forward your queries. ‘proxy-lua-script’ – is the full path to the .lua script from mysql proxy bundle. Be sure to use the full path, otherwise you’d get the error:

2010-04-28 01:21:56: (critical) ..\src\network-mysqld-lua.c:232: lua_load_file(C:\downloads\mysql-proxy-0.8.0-win32-x86\..\share\doc\mysql-proxy\tutorial-basic.lua) failed: ..\src\lua-scope.c:239: stat(C:\downloads\mysql-proxy-0.8.0-win32-x86\..\share\doc\mysql-proxy\tutorial-basic.lua) failed: No error (0)

3. create a .bat and add it to your startup (if you wish of course)
4. By default it listens on 4040 port, so you should reconfig the app you want to debug to connect to localhost:4040
Here is the screenshot of working proxy:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.