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 Monitor Semua SQL Queries di 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 memiliki alat yang disebut profiler yang dapat Anda gunakan untuk memantau setiap SQL query yang hits database. This is extremely useful for programmers as well as database administrators to troubleshoot the exact queries generated by an application. Ini sangat berguna untuk programmer serta database administrator untuk memecahkan masalah yang tepat query yang dihasilkan oleh aplikasi.

Having switched to using MySQL on a frequent basis, this was one of the first things I wanted to figure out how to do. Setelah beralih menggunakan MySQL pada dasar yang sering, ini adalah salah satu hal pertama yang saya ingin mengetahui bagaimana melakukannya. How else can you see the actual SQL code generated by Wordpress or phpBB? Bagaimana lagi yang bisa Anda lihat kode SQL yang sebenarnya dihasilkan oleh Wordpress atau phpBB?

The first thing we'll need to do is turn on logging of queries in MySQL. Hal pertama yang harus kita lakukan adalah menghidupkan pertanyaan penebangan di MySQL. Be warned that this should only be done in development… it really slows things down to log every single query to a file. Jadilah memperingatkan bahwa hal ini hanya boleh dilakukan dalam pembangunan ... itu benar-benar memperlambat segalanya untuk mendata setiap satu query ke file.

Find and open your MySQL configuration file, usually /etc/mysql/my.cnf on Ubuntu. Cari dan buka file konfigurasi MySQL, biasanya / etc / mysql / my.cnf pada Ubuntu. Look for the section that says “Logging and Replication” Cari bagian yang mengatakan "Pembalakan dan Replika"

# #
# * Logging and Replication # * Logging dan Replika
# #
# Both location gets rotated by the cronjob. # Kedua lokasi akan diputar oleh Cronjob.
# Be aware that this log type is a performance killer. # Perlu diketahui bahwa jenis log ini adalah pembunuh kinerja.

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

Just uncomment the “log” variable to turn on logging. Hanya tanda komentar pada "log" variabel untuk mengaktifkan logging. Restart MySQL with this command: Restart MySQL dengan perintah:

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. Sekarang kita siap untuk mulai memantau queries saat mereka masuk Buka terminal baru dan jalankan perintah ini untuk menggulir file log, menyesuaikan jalan jika perlu.

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

Now run your application. Sekarang jalankan aplikasi Anda. You'll see the database queries start flying by in your terminal window. Anda akan melihat database queries mulai terbang dengan dalam jendela terminal anda. (make sure you have scrolling and history enabled on the terminal) (pastikan anda telah bergulir dan sejarah diaktifkan pada terminal)

I'm impressed, phpbb3 has fairly tight, optimized SQL code. Aku terkesan, phpbb3 telah cukup ketat, dioptimalkan kode SQL. Wordpress, on the other hand, is very inefficient. Wordpress, di sisi lain, sangat tidak efisien.

This article was originally written on 05/16/07 Tagged with: Artikel ini awalnya ditulis pada 05/16/07 Tagged with: Database Database

Daily Email Updates Harian Email Pembaharuan

You can get our how-to articles in your inbox each day for free. Anda bisa mendapatkan kita bagaimana-untuk artikel dalam kotak masuk Anda setiap hari secara gratis. Just enter your name and email below: Cukup masukkan nama dan email Anda di bawah ini:


Name: Nama:
Email: Email:

Comments (4) Komentar (4)

  1. supermansghost supermansghost

    This is an awesome tip. Ini adalah tip awesome.

  2. JTMcNaught JTMcNaught

    This is exactly what I needed to help me optimize my growing website. Ini adalah apa yang saya butuhkan untuk membantu saya tumbuh mengoptimalkan situs. 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. Terima kasih kepada How-To-Geek, banyak jam frustrasi saya sudah diselamatkan dan sekarang saya akhirnya bisa menganalisis beban freqency dan stres yang disebabkan oleh semua query yang berbeda memukul server MYSQL dan akhirnya menyelesaikan beberapa masalah kinerja slowdowns dan karena ke beban.

    With appreciation! Dengan penghargaan!

    JTMcNaught JTMcNaught

  3. Alain Alain

    Thank you, I was trying to remember how to do this. Terima kasih, saya mencoba mengingat bagaimana melakukan hal ini.
    The information is concise and precise. Informasi ini ringkas dan tepat. Right to the point. Langsung ke titik.

  4. Jaris Jaris

    Thank you! Terima kasih!
    Exactly what I needed! Persis apa yang saya butuhkan!


Leave a Comment Tinggalkan Komentar




Leave your Meninggalkan friendly ramah comment here. komentar di sini.

If you have a computer help question, Jika Anda memiliki pertanyaan bantuan komputer, click here to leave it on the forums klik di sini untuk meninggalkannya di forum instead. selain.

Note: Your comment may not show up immediately on the site. Catatan: Komentar anda mungkin tidak muncul segera di situs.

Our Friends Our Friends
Getting Started Persiapan


About How-To Geek Tentang How-To Geek
What Is That Process? Apa Proses Itu?
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.