潸死蝔撘瑁敺, 嗡葉銝閬瑼X亦唳寞航摨怒MySQL 臭誑撠瑁 SQL 隤亙券函銝靘, 臭誑芣臬瑁Y SQL 隤亦銝靘, 璅撠 MySQL 隤亦 Debug 撠梯擛敺憭鈭
# \8 [" Z( y8 O7 C. K* Z$ l) x0 {; N) o/ S* S/ ]
閬蝝瑁Y SQL 隤, 臭誑靽格 my.cnf 摰, my.cnf 憭詨其誑銝雿蝵:
5 ?9 Z7 j0 g4 {4 E+ j4 C
! v% ?( m$ F# t5 s! N/etc/my.cnf( @0 ~7 l& V7 N3 D& u6 w0 o4 t
/etc/mysql/my.cnf
, F/ B. b" u4 F/ F7 P4 b5 a
B; h2 D/ P# p4 t/ i" R/ Z: I my.cnf, [mysqld] 畾菔賢乩誑銝撟曇:
1 i+ j( A7 a$ c% ^+ Wslow_query_log = 12 C4 U* G) T8 B+ U, _ H% \- l
slow_query_log_file = /var/log/mysql-slow.log
; @4 s& s: j& h5 L& ^/ glong_query_time = 2 5 B0 b" \' G+ w6 z7 [0 u; ?
隞乩撟曇交:
* `+ P7 k* u9 |/ I/ B* h. K0 M M* n2 B& b. w& Z* F
slow_query_log = 1- N7 E. F0 |( W$ V
蝝瑁Y SQL 隤:: b) R- @2 p: J* y6 w. ?+ d% U8 S
) ?3 s4 x7 z' Z5 I" l3 x( J* ]
slow_query_log_file = /var/log/mysql-slow.log/ n5 x8 b, I$ V& b/ s2 H1 o& t4 F; y
閮剖蝝瑼雿蝵桀 /var/log/mysql-slow.log4 c4 k! l# h6 f( X: J# q
* k0 T$ H3 ]! t( G- x& u
long_query_time = 2
/ V% j' W1 g" M4 d( @閮剖 SQL 隤亙瑁頞 2 蝘, 靘踵撠 SQL 隤亙脣
! P- b/ t% B; _% X$ ]. X* I$ z3 U( k$ S5 d. u6 |2 S
靽格孵末 my.cnf 敺, 啣 MySQL 靘踹鈭5 W* d1 Y2 m& r& N. Y
+ Z0 p( [( J- @2 W/ R7 k* A% n( A( T: i( k
|
|