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.

Monitor All SQL Queries in MySQL Sledovať všetky SQL dotazov v MySQL

Microsoft's SQL Server has a tool called Profiler that you can use to monitor every SQL query that hits the database. Microsoft SQL Server je nástroj s názvom Profiler, ktorý môžete použiť na sledovanie každého SQL dotaze, ktorý vyráža na databázu. This is extremely useful for programmers as well as database administrators to troubleshoot the exact queries generated by an application. To je veľmi užitočné pre programátorov a správcov databáz na riešenie presné otázky generované aplikácie.

Having switched to using MySQL on a frequent basis, this was one of the first things I wanted to figure out how to do. Po prepnutí na používanie MySQL na často, to bola jedna z prvých vecí, ktoré som chcel prísť na to, ako to urobiť. How else can you see the actual SQL code generated by Wordpress or phpBB? Ako inak si môžete zobraziť aktuálne SQL kód vygenerovaný Wordpress a phpBB?

The first thing we'll need to do is turn on logging of queries in MySQL. Prvá vec, ktorú budeme musieť urobiť, je zapnúť logovanie dotazov v MySQL. Be warned that this should only be done in development… it really slows things down to log every single query to a file. Byť upozornení, že by to malo byť vykonané v rozvojových ... je to naozaj spomaľuje, čo sa prihlásiť každý jednotlivý otázku do súboru.

Find and open your MySQL configuration file, usually /etc/mysql/my.cnf on Ubuntu. Nájdite a otvorte si MySQL konfiguračný súbor, zvyčajne / etc / mysql / my.cnf na Ubuntu. Look for the section that says “Logging and Replication” Pozrite sa na sekcii, ktorá hovorí, že "Logging and Replication"

# #
# * Logging and Replication # * Logovanie a replikácie
# #
# Both location gets rotated by the cronjob. # Obaja miesto dostane otáča cronjob.
# Be aware that this log type is a performance killer. # Majte na pamäti, že tento typ je záznam predstavenia vrah.

log = /var/log/mysql/mysql.log log = / var / log / mysql / mysql.log

Just uncomment the “log” variable to turn on logging. Len odkomentovat "log" premenné zapnúť logovanie. Restart MySQL with this command: Restart MySQL s týmto príkazom:

sudo /etc/init.d/mysql restart sudo / etc / init.d / mysql restart

Now we're ready to start monitoring the queries as they come in. Open up a new terminal and run this command to scroll the log file, adjusting the path if necessary. Teraz sme pripravení začať sledovať otázky, ako prichádzajú dovnútra Otvorte nový terminál a spustenie tohto príkazu pre posunutie log súboru, nastavenie trasy v prípade potreby.

tail -f /var/log/mysql/mysql.log chvost-f / var / log / mysql / mysql.log

Now run your application. Teraz spustite aplikáciu. You'll see the database queries start flying by in your terminal window. Uvidíte v databáze dotazov štart rokmi v okne terminálu. (make sure you have scrolling and history enabled on the terminal) (skontrolujte, či máte povolené posúvanie a histórie na termináli)

I'm impressed, phpbb3 has fairly tight, optimized SQL code. Mám dojem, phpbb3 je docela tesný, optimalizovaný kód SQL. Wordpress, on the other hand, is very inefficient. Wordpress, na druhej strane, je veľmi neefektívne.

This article was originally written on 05/16/07 Tagged with: Tento článok bol pôvodne napísaný na 05/16/07 Tagged s: Database Databáza

Daily Email Updates Denný Svářeč

You can get our how-to articles in your inbox each day for free. Môžete si naše jak-na články vo vašej schránky každý deň zadarmo. Just enter your name and email below: Stačí zadať svoje meno a e-mail nižšie:


Name: Meno:
Email: E-mail:

Comments (4) Komentáre (4)

  1. supermansghost supermansghost

    This is an awesome tip. To je úžasné tip.

  2. JTMcNaught JTMcNaught

    This is exactly what I needed to help me optimize my growing website. To je presne to, čo som potreboval, aby mi pomohol optimalizovať rastúce webových stránkach. Thanks to How-To-Geek, many hours of frustration of mine have been saved and now I can finally analyse the freqency and stress loads caused by all of the different queries hitting the MYSQL server and finally resolve some of the slowdowns and performance issues due to the load. Vďaka How-To-Geek, bolo veľa hodín frustrácie banských zachránil a teraz môžem konečne analyzovať freqency stresu a záťaže spôsobenej všetkými rôznych dotazov biť MySQL servera, a konečne vyriešiť niektoré problémy s výkonom a spomalenie vďaka to the load.

    With appreciation! S uznaním!

    JTMcNaught JTMcNaught

  3. Alain Alain

    Thank you, I was trying to remember how to do this. Ďakujem, som sa snažil spomenúť si, ako to urobiť.
    The information is concise and precise. Informácie sú stručné a presné. Right to the point. Právo k veci.

  4. Jaris Jaris

    Thank you! Ďakujeme vám!
    Exactly what I needed! Presne to, čo som potreboval!


Our Friends Naši priatelia
Getting Started Začíname


About How-To Geek O tom, ako-To Geek
What Is That Process? Čo je to za proces?
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.