Important! This is an automatic machine translated page. If you can read english, you should Click Here to read the original English version of the article.

Track MySQL Queries with mysqlsniffer on Ubuntu Sekti MySQL queries su mysqlsniffer Ubuntu

You've got a production database server, and you can't enable query logging… so how do you see the queries being executed against the database? You've got gamybos duomenų bazės serverio, ir jūs negalite įjungti užklausa prisijungti ... Taigi, kaip matote užklausų yra vykdomas nuo duomenų bazės?

The answer: use a modified network sniffer to parse out the MySQL packets and decode them. Atsakymas: naudokite kartą tinklas Sniffer ardyti iš MySQL paketus ir juos iššifruoti. You'll have to do a little compiling, but it'll be worth it. Jūs turėsite padaryti tiek rengiant, bet tai bus verta to. Note that this will not usually work for local connections, although you are welcome to try. Atkreipkite dėmesį, kad tai bus ne paprastai darbo sujungimo vietos, nors jūs galite pabandyti.

First, you need to install libpcap-dev, which is the development library that allows an application to sniff network packets. Pirma, jums reikia įdiegti libpng-dev, kuris yra biblioteka, kuri leidžia taikyti prunkštelėti tinklo paketus.

sudo apt-get install libpcap-dev sudo apt-get install libpng-dev

Now let's make a directory, download the source code and compile it Dabar Pakelkime katalogą, parsisiųsti išeities kodą ir kaupia jį

mkdir mysqlsniffer mkdir mysqlsniffer

cd mysqlsniffer CD mysqlsniffer

wget hackmysql.com/code/mysqlsniffer.tgz wget hackmysql.com / kodas / mysqlsniffer.tgz

tar xvfz mysqlsniffer.tgz deguto xvfz mysqlsniffer.tgz

gcc -O2 -lpcap -o mysqlsniffer mysqlsniffer.c packet_handlers.c misc.c gcc-O2-lpcap-o mysqlsniffer mysqlsniffer.c packet_handlers.c misc.c

At this point, we have a shiny new executable named mysqlsniffer in our source directory. Šiuo metu mes visiškai naujos vykdomąjį pavadintas mysqlsniffer mūsų kataloge šaltinio. You can copy it wherever you like (somewhere in the path would be useful) Jūs galite kopijuoti jį ten, kur jums patinka (kažkur kelyje būtų naudinga)

To run mysqlsniffer, you need to specify the network interface that MySQL is listening on. Paleisti mysqlsniffer, būtina nurodyti tinklo sąsaja MySQL klausytis. For me, it's eth0. Man tai eth0.

sudo /path/to/mysqlsniffer eth0 sudo / kelias / iki / mysqlsniffer eth0

Loads of stuff starts flying by… let's filter it out a little more so we can just get the queries and not all the excess data. Loads of stuff prasideda skraido ... let's filtras jį šiek tiek daugiau, kad mes galėtume tiesiog gauti klausimus ir ne visus perteklius duomenų.

$ sudo /path/to/mysqlsniffer –no-mysql-hdrs eth0 | grep COM_QUERY $ Sudo / kelias / iki / mysqlsniffer-no-mysql-hdrs eth0 | grep COM_QUERY

192.168.73.1.2622 > server: COM_QUERY: SELECT @@sql_mode 192.168.73.1.2622> Serveris: COM_QUERY: SELECT @ @ sql_mode
192.168.73.1.2622 > server: COM_QUERY: SET SESSION sql_mode=” 192.168.73.1.2622> Serveris: COM_QUERY: SET sesija sql_mode = "
192.168.73.1.2622 > server: COM_QUERY: SET NAMES utf8 192.168.73.1.2622> Serveris: COM_QUERY: SET utf8 PAVADINIMAI
192.168.73.1.1636 > server: COM_QUERY: SELECT @@SQL_MODE 192.168.73.1.1636> Serveris: COM_QUERY: SELECT @ @ SQL_MODE
192.168.73.1.1636 > server: COM_QUERY: SHOW FULL COLUMNS FROM `db2842_howto`.`wp_users` 192.168.73.1.1636> Serveris: COM_QUERY: Rodyti visą stulpelius "db2842_howto". "Wp_users`

Ah, now there we are… all sorts of query information, without having to restart MySQL. Ach, dabar ten mes ... visi užklausa rūšių informacijos, nereikia perkrauti MySQL.

Here are the full options for the command: Čia yra visos galimybės komandą:

Usage: mysqlsniffer [OPTIONS] INTERFACE Naudojimas: mysqlsniffer [options] SĄSAJA

OPTIONS: Pasirinktys:
–port N Listen for MySQL on port number N (default 3306) Uosto N Listen for MySQL prievado numeris N (default 3306)
–verbose Show extra packet information -Verbose Rodyti papildomą paketą informacija
–tcp-ctrl Show TCP control packets (SYN, FIN, RST, ACK) -Tcp-Ctrl Rodyti TCP valdymo paketus (SYN, FIN, RST, ACK)
–net-hdrs Show major IP and TCP header values -Net-hdrs Rodyti didelių IP ir TCP header vertybės
–no-mysql-hdrs Do not show MySQL header (packet ID and length) -No-mysql-hdrs Nerodyti MySQL header (packet ID ir ilgį)
–state Show state -Rodyti valstybės narė
–v40 MySQL server is version 4.0 -V40 MySQL serverio versijos 4.0
–dump Dump all packets in hex -Dump dump visų HEX paketais
–help Print this -Help Spausdinti

Original source code and more information at: Originalaus kodo ir daugiau informacijos:
http://hackmysql.com/mysqlsniffer http://hackmysql.com/mysqlsniffer

If you are running on a development server, it would be easier to just Jei dirbate su plėtros serverio, kad būtų lengviau tiesiog turn on query logging įjungti užklausa prisijungti . .

This article was originally written on 05/25/07 Tagged with: Šis straipsnis buvo parašytas ant 05/25/07 Tagged with: Ubuntu Ubuntu

Daily Email Updates Dienos paštas Atnaujinimai

You can get our how-to articles in your inbox each day for free. Galite gauti mūsų kaip prie straipsnių į Jūsų pašto dėžutę kasdien nemokamai. Just enter your name and email below: Tiesiog įveskite vardą ir elektroninio pašto adresą žemiau:


Name: Pavadinimas:
Email: Paštas:

Our Friends Mūsų draugai
Getting Started Paruo


About How-To Geek Apie How-To Geek
What Is That Process? Kas yra šis procesas?
svchost.exe svchost.exe
jusched.exe jusched.exe
dwm.exe dwm.exe
ctfmon.exe Ctfmon.exe
wmpnetwk.exe wmpnetwk.exe
wmpnscfg.exe wmpnscfg.exe
rundll32.exe rundll32.exe
wfcrun32.exe wfcrun32.exe
Ipoint.exe Ipoint.exe
Itype.exe Itype.exe
Wfica32.exe Wfica32.exe
Mobsync.exe Mobsync.exe
conhost.exe conhost.exe
Dpupdchk.exe Dpupdchk.exe Adobe_Updater.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com. Copyright © 2006-2009 HowToGeek.com. All Rights Reserved. All Rights Reserved.