Foros de discusión

See raw MySQL queries from Liferay and elsewhere

thumbnail
James Falkner, modificado hace 8 años.

See raw MySQL queries from Liferay and elsewhere

Liferay Legend Mensajes: 1399 Fecha de incorporación: 17/09/10 Mensajes recientes
Are you using a local MySQL instance with Liferay, and want to see the actual sql being issued to the database (without all those pesky placeholders, instead with the actual values)?

I found this nice script that works on most unix OS's (including OS X) and shall re-post it here with kudos to Maciej. It may need modification if you are doing non-stock configuration (ports, protocols, etc). Also it must be normally run with superuser privs (e.g. sudo).


#!/bin/bash
#this script used monitor mysql network traffic.echo sql
tcpdump -i any -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
    if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL)/i)
    {
        if (defined $q) { print "$q\n"; }
        $q=$_;
    } else {
        $_ =~ s/^[ \t]+//; $q.=" $_";
    }
}'
thumbnail
David H Nebinger, modificado hace 8 años.

RE: See raw MySQL queries from Liferay and elsewhere

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Isn't that what we use p6spy for?
thumbnail
James Falkner, modificado hace 8 años.

RE: See raw MySQL queries from Liferay and elsewhere

Liferay Legend Mensajes: 1399 Fecha de incorporación: 17/09/10 Mensajes recientes

[jhf@JamesFaBPUpdate]  ~  $ p6spy
-bash: p6spy: command not found
thumbnail
David H Nebinger, modificado hace 8 años.

RE: See raw MySQL queries from Liferay and elsewhere

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
?

It's not a command, it works as a JDBC driver to log everything and it's database-neutral.

https://p6spy.github.io/p6spy/
thumbnail
James Falkner, modificado hace 8 años.

RE: See raw MySQL queries from Liferay and elsewhere

Liferay Legend Mensajes: 1399 Fecha de incorporación: 17/09/10 Mensajes recientes
;) p6spy is nice no doubt, but it requires installation, restarting the server, modifying files, etc. The script you just run and it works with no special setup or no server restarts using out of the box unix tools. It only works in the default case of MySQL running locally on port 3306.