Subscribe to How-To Geek Mag-subscribe sa Paano-Upang Geek

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 Subaybayan ang lahat ng mga SQL Queries sa MySQL

Microsoft's SQL Server has a tool called Profiler that you can use to monitor every SQL query that hits the database. Microsoft's SQL Server ay isang kasangkapan na tinatawag na Profiler na maaari mong gamitin upang masubaybayan ang bawat SQL query na hits sa database. This is extremely useful for programmers as well as database administrators to troubleshoot the exact queries generated by an application. Ito ay lubhang kapaki-pakinabang para sa mga programmer pati na rin ang database administrator upang ayusin ang eksaktong tanong na nabuo sa pamamagitan ng isang application.

Having switched to using MySQL on a frequent basis, this was one of the first things I wanted to figure out how to do. Ang pagkakaroon ng inililipat sa gamit ang MySQL sa isang madalas na batayan, ito ay isa sa mga unang bagay na nais ko na malaman kung paano gawin. How else can you see the actual SQL code generated by Wordpress or phpBB? Paano pa ang maaari mong makita ang aktwal na code SQL nabuo sa pamamagitan ng Wordpress o phpBB?

The first thing we'll need to do is turn on logging of queries in MySQL. Ang unang bagay na kakailanganin naming gawin ay buksan ang pag-log in ng mga tanong sa MySQL. Be warned that this should only be done in development… it really slows things down to log every single query to a file. Maging babala na ito ay dapat lamang gawin sa pag-unlad ... ito tunay slows down na mga bagay-bagay upang mag-log ang bawat isang tanong sa isang file.

Find and open your MySQL configuration file, usually /etc/mysql/my.cnf on Ubuntu. Hanapin at buksan ang iyong MySQL configuration file, kadalasang / etc / MySQL / my.cnf sa Ubuntu. Look for the section that says “Logging and Replication” Hanapin ang seksyon na nagsasabing "Logging at pagtitiklop"

# #
# * Logging and Replication # * Pumapasok at pagtitiklop
# #
# Both location gets rotated by the cronjob. # Lokasyon Parehong gets Pinaikot ng cronjob.
# Be aware that this log type is a performance killer. # Magkaroon ng kamalayan na ito ay mag-log ng uri ng pagganap ng isang mamamatay.

log = /var/log/mysql/mysql.log mag-log = / var / log / MySQL / mysql.log

Just uncomment the “log” variable to turn on logging. Just uncomment ang "log" variable sa turn on pag-log in. Restart MySQL with this command: I-restart ang MySQL gamit ang utos:

sudo /etc/init.d/mysql restart sudo / etc / init.d / MySQL i-restart ang

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. Ngayon kami ay handa na upang simulan ang pagsubaybay ng mga tanong gaya sila lumapit ka Buksan up ng isang bagong terminal at magpatakbo ng command na ito upang mag-scroll ang log file, pag-aayos ang landas na kung kinakailangan.

tail -f /var/log/mysql/mysql.log buntot-f / var / log / MySQL / mysql.log

Now run your application. Ngayon patakbuhin ang iyong aplikasyon. You'll see the database queries start flying by in your terminal window. Makikita mo ang mga database ng mga tanong magsimula sa pamamagitan ng paglipad sa iyong terminal window. (make sure you have scrolling and history enabled on the terminal) (siguraduhin na mag-iskrol at kasaysayan naka-enable sa terminal)

I'm impressed, phpbb3 has fairly tight, optimized SQL code. I'm impressed, phpbb3 ay medyo masikip, optimized SQL code. Wordpress, on the other hand, is very inefficient. Wordpress, sa ibang dako, ay tunay hindi mabisa.

This article was originally written on 05/16/07 Tagged with: Ang artikulong ito ay orihinal na isinulat sa 05/16/07 Tagged with: Database Database

Daily Email Updates Araw-araw na Updates Email

You can get our how-to articles in your inbox each day for free. Maaari kang makakuha ng aming kung-paano na mga artikulo sa iyong inbox sa bawat araw para sa libre. Just enter your name and email below: Ilagay lamang ang inyong pangalan at email sa ibaba:


Name: Pangalan:
Email: Email:

Comments (4) Comments (4)

  1. supermansghost supermansghost

    This is an awesome tip. Ito ay isang awesome tip.

  2. JTMcNaught JTMcNaught

    This is exactly what I needed to help me optimize my growing website. Ito ay kung ano mismo ang kailangan ko upang makatulong sa akin-optimize ang aking lumalaki website. 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. Salamat sa Paano-To-Geek, maraming mga oras ng pagkabigo ng mga mina ay nai-save at ngayon ako sa wakas analyse ang freqency at stress naglo-load na sanhi ng lahat ng mga iba't-ibang tanong sa paghagupit ang MySQL server at sa wakas malutas ang ilan sa mga slowdowns at pagganap ng mga isyu sa angkop na sa load.

    With appreciation! Sa pamamagitan ng appreciation!

    JTMcNaught JTMcNaught

  3. Alain Alain

    Thank you, I was trying to remember how to do this. Salamat sa iyo, ako ay sisikaping matandaan kung paano gawin ito.
    The information is concise and precise. Ang impormasyon ay maigsi at tiyak. Right to the point. Karapatan na ang point.

  4. Jaris Jaris

    Thank you! Salamat!
    Exactly what I needed! Kung ano mismo ang kailangan ko!


Our Friends Ang aming mga Friends
Getting Started Pagsisimula


About How-To Geek Tungkol sa Paano-Upang Geek
What Is That Process? Ano ba ang Proseso Iyon?
svchost.exe svchost.exe
jusched.exe jusched.exe
dwm.exe dwm.exe
ctfmon.exe ctfmon.exe
wmpnetwk.exe wmpnetwk.exe
mDNSResponder.exe mDNSResponder.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.