Catch queries with MySQL Proxy

Asked by Kekko

Hi all!!
I installed mysql proxy and working properly. Now, through mysql proxy, I want to capture the SQL queries that are generated by a web application when, for example, was completed a form input.
P.S. I will try everything to localhost, if possible.
Does anyone know help me?
I apologize for my bad English!
Thank you very much!

Question information

Language:
English Edit question
Status:
Answered
For:
MySQL Proxy Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

Revision history for this message
fmpwizard (diego-fmpwizard) said :
#1

Hi,

Try this one

http://forge.mysql.com/tools/tool.php?id=80

Thanks

   -Diego

On Mon, Jan 4, 2010 at 1:28 PM, Kekko
<email address hidden> wrote:
> New question #96189 on MySQL Proxy:
> https://answers.launchpad.net/mysql-proxy/+question/96189
>
> Hi all!!
> I installed mysql proxy and working properly. Now, through mysql proxy, I want to capture the SQL queries that are generated by a web application when, for example, was completed a form input.
> P.S. I will try everything to localhost, if possible.
> Does anyone know help me?
> I apologize for my bad English!
> Thank you very much!
>
> --
> You received this question notification because you are a member of
> MySQL Proxy Discuss, which is an answer contact for MySQL Proxy.
>

--
Diego Medina
Web Developer
http://www.fmpwizard.com

Revision history for this message
Kekko (kekkop) said :
#2

First thanks for your response!
I've used this script and writing the SQL queries in a shell ms dos (client) after starting EasyPhp, it works perfectly. But I would like to use this script to capture the SQL queries generated by a web application (web site in localhost) and i don't know how to do it!
Do you know to do this?
Thank you very much!

Revision history for this message
A Porter Felt (apf) said :
#3

What do you mean by "capture the SQL queries"?

That script should print out all of the queries to the console. What else do you want it to do?

If you aren't seeing output, make sure that your web app is connecting to the same port that MySQL proxy is listening to.

Revision history for this message
Kekko (kekkop) said :
#4

What do you mean by "capture the SQL queries"?

1) I start EasyPhp.
2) I open a shell of ms dos(prompt) and write : mysql-proxy --proxy-lua-script="ClientValidaton.lua" (ClientValidation is the script that captures SQL queries entered by the client)
3) I open another shell of ms dos(prompt), write mysql -u root -P 4040 -h 127.0.0.1. Now all SQL queries that I insert, are properly captured and are written to a file. txt!

That script should print out all of the queries to the console. What else do you want it to do?

I would try to capture the SQL queries that are generated by a web application when, for example, a form has been filled (this site I have it in localhost and not yet networked).

I basically try this script for a web application (website) and do not capture queries that are entered manually through the shell

Revision history for this message
Kekko (kekkop) said :
#5

What do you mean by "capture the SQL queries"?
1) I start EasyPhp.
2) I open a shell of ms dos(prompt) and write : mysql-proxy --proxy-lua-script="ClientValidaton.lua" (ClientValidation is the script that captures SQL queries entered by the client)
3) I open another shell of ms dos(prompt), write mysql -u root -P 4040 -h 127.0.0.1. Now all SQL queries that I insert, are properly captured and are written to a file. txt!
That script should print out all of the queries to the console. What else do you want it to do?
I would try to capture the SQL queries that are generated by a web application when, for example, a form has been filled (this site I have it in localhost and not yet networked).
I basically try this script for a web application (website) and do not capture queries that are entered manually through the shell

Revision history for this message
Kekko (kekkop) said :
#6

What do you mean by "capture the SQL queries"?
1) I start EasyPhp.
2) I open a shell of ms dos(prompt) and write : mysql-proxy --proxy-lua-script="ClientValidaton.lua" (ClientValidation is the script that captures SQL queries entered by the client)
3) I open another shell of ms dos(prompt), write mysql -u root -P 4040 -h 127.0.0.1. Now all SQL queries that I insert, are properly captured and are written to a file. txt!
That script should print out all of the queries to the console. What else do you want it to do?
I would try to capture the SQL queries that are generated by a web application when, for example, a form has been filled (this site I have it in localhost and not yet networked).
I basically try this script for a web application (website) and do not capture queries that are entered manually through the shell

Revision history for this message
Chris Calender (chriscalender) said :
#7

You'll need to parse the queries to determine whether or not they come from the web application or not. And then print out those queries that fit your criteria.

Do these queries have some unique identifier?

If so, that would make this much easier.

However, if not, then you could add a comment to the query, in your code (i.e., SELECT /* comment */ FROM table WHERE ...). And then when parsing the query via proxy, you could look for that comment. That would make it easy to identify the queries you want to capture.

Also, you must make sure your application connects to port 4040 instead of port 3306.

Revision history for this message
Kekko (kekkop) said :
#8

Unfortunately I did not write this application web but I created it with Joomla!
However, I want to know: can I test this script (for the capture of queries generated by application) in localhost?
if so, what should I do?

Revision history for this message
Matthew (mboehm) said :
#9

If all you want is to capture queries, why not just use the general_query_log?

Revision history for this message
Kekko (kekkop) said :
#10

Because I have already written most of the code for my thesis work and if I should use general_query_log, throw almost everything I've done

Revision history for this message
fmpwizard (diego-fmpwizard) said :
#11

Hi,

Once you have your mysql proxy running, you would need to change the
port that the php app uses from 3306 to 4040 as someone already said.

Just having a proxy running on your machine does not capture queries,
you need to send traffic through the proxy (maybe you thought the
proxy could work like some http sniffer, but it dies not)

Thanks

  -Diego

On Mon, Jan 4, 2010 at 3:39 PM, Kekko
<email address hidden> wrote:
> Question #96189 on MySQL Proxy changed:
> https://answers.launchpad.net/mysql-proxy/+question/96189
>
>    Status: Answered => Open
>
> Kekko is still having a problem:
> Because I have already written most of the code for my thesis work and
> if I should use general_query_log, throw almost everything I've done
>
> --
> You received this question notification because you are a member of
> MySQL Proxy Discuss, which is an answer contact for MySQL Proxy.
>

--
Diego Medina
Web Developer
http://www.fmpwizard.com

Can you help with this problem?

Provide an answer of your own, or ask Kekko for more information if necessary.

To post a message you must log in.