Monitor All SQL Queries in MySQL Monitor Visi SQL vaicājumu 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 ir instruments, ko sauc Profiler, kuru varat izmantot, lai pārraudzītu visas SQL vaicājumu, kas hits datu bāzē. This is extremely useful for programmers as well as database administrators to troubleshoot the exact queries generated by an application. Tas ir ļoti noderīgs programmētājiem, kā arī datu bāzes administrators rst precīzu jautājumiem, ko pieteikumu.
Having switched to using MySQL on a frequent basis, this was one of the first things I wanted to figure out how to do. Ņemot pārslēdz izmantojot MySQL uz bieži, šī bija viena no pirmajām lietām, es gribēju izdomāt, kā to izdarīt. How else can you see the actual SQL code generated by Wordpress or phpBB? Kā gan citādi jūs varat redzēt faktisko SQL kods, by Wordpress vai phpBB?
The first thing we'll need to do is turn on logging of queries in MySQL. Pirmā lieta, kas mums būs jādara, ir ieslēgt anos queries in MySQL. Be warned that this should only be done in development… it really slows things down to log every single query to a file. Jābrīdina, ka tas būtu tikai tad, attīstības ... tiešām kavē lietas, uz leju, lai pieteiktos katru vaicājumu fails.
Find and open your MySQL configuration file, usually /etc/mysql/my.cnf on Ubuntu. Atrast un atvērt savu MySQL konfigurācijas failu, parasti / etc / mysql / my.cnf par Ubuntu. Look for the section that says “Logging and Replication” Meklēt sadaļu, kas saka "Reģistrēšana un Replication"
# #
# * Logging and Replication # * Reģistrēšana un Replication
# #
# Both location gets rotated by the cronjob. # Abas atrašanās vieta kļūst pagriezti par cronjob.
# Be aware that this log type is a performance killer. # Ņemiet vērā, ka tas log veida darbības killer.log = /var/log/mysql/mysql.log log = / var / log / mysql / mysql.log
Just uncomment the “log” variable to turn on logging. Just uncomment ", žurnāls" mainīgo lielumu, lai ieslēgtu mežizstrādi. Restart MySQL with this command: Restart MySQL ar šo komandu:
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. Tagad mēs esam gatavi sākt pārraudzīt jautājumus, kā viņi nāk iekšā Open up jaunu terminālu un palaist šo komandu, lai ritinātu log failu, regulē ceļu, ja nepieciešams.
tail -f /var/log/mysql/mysql.log tail-f / var / log / mysql / mysql.log
Now run your application. Tagad rādīt jūsu pieteikumu. You'll see the database queries start flying by in your terminal window. Jūs redzēsiet datubāzes vaicājumu sākt lidojot jūsu termināļa logā. (make sure you have scrolling and history enabled on the terminal) (pārliecinieties, ka Jums ir ritināšanas un vēsture aktiviz Terminal)

I'm impressed, phpbb3 has fairly tight, optimized SQL code. Es esmu pārsteigts, phpbb3 ir diezgan saspringts, optimizēta SQL kodu. Wordpress, on the other hand, is very inefficient. WordPress, no otras puses, ir ļoti neefektīva.

Daily Email Updates Daily Email Updates
You can get our how-to articles in your inbox each day for free. Jūs varat saņemt mūsu how-to rakstus savā pastkastītē katru dienu par brīvu. Just enter your name and email below: Vienkārši ievadiet jūsu vārdu un e-pasta zemāk:



This is an awesome tip. Šī ir awesome tip.
This is exactly what I needed to help me optimize my growing website. Tas ir tieši tas, ko man vajadzēja man palīdzēs optimizēt manu augošo mājas lapā. 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. Pateicoties How-To-Kanāda, daudzas stundas neapmierinātību mīnu tika saglabāti un tagad es beidzot var analizēt freqency un stresa slodzēm, ko izraisa visas dažādās queries hitting MySQL servera un beidzot atrisināt dažas lejupslīdi, un veiktspējas problēmas, jo ar kravu.
With appreciation! Ar gandarījumu!
JTMcNaught JTMcNaught
Thank you, I was trying to remember how to do this. Paldies, es centos atcerēties, kā to izdarīt.
The information is concise and precise. Informācija ir īss un precīzs. Right to the point. Tiesības punktu.
Thank you! Paldies!
Exactly what I needed! Tieši tas, ko man vajadzēja!