BlogYoutube

Enabling MySQL slow query log using XAMPP

By nikhil 15 days ago
<div contenteditable="true" data-gramm_id="98c8d428-3406-32a1-7f92-c2d977f6fb2a" data-gramm="true" spellcheck="false" data-gramm_editor="true">Sometimes we need to check which MySQL queries are slow and should be optimized, By enabling  MySQL slow query log  we can easily see which MySQL queries are slow and should be optimized
  follow the steps to enable MySQL slow query

Step 1 : Open my.ini file

we simply need to click config button in XAMPP for MySQL and click on the my.ini 
image loading..

Step 2 : Add following two lines in the [mysqld] block in my.ini

<div contenteditable="true" data-gramm_id="530d50ee-32e8-a4af-419e-b90bdb92dab8" data-gramm="true" spellcheck="false" data-gramm_editor="true">slow_query_log = 1
slow-query-log-file=/var/log/mysql-slow.log
 
 so [mysqld] part of mysql.ini would look like this, (note last two lines)
 
 
  # The MySQL server
   [mysqld] 
 port= 3306
   socket = "C:/xampp/mysql/mysql.sock" 
 basedir = "C:/xampp/mysql" tmpdir = "C:/xampp/tmp" 
 datadir = "C:/xampp/mysql/data"
   pid_file = "mysql.pid"
   # enable-named-pipe 
 key_buffer = 16M 
 max_allowed_packet = 1M 
 sort_buffer_size = 512K 
 net_buffer_length = 8K
 read_buffer_size = 256K
 read_rnd_buffer_size = 512K 
 myisam_sort_buffer_size = 8M 
 log_error = "mysql_error.log" 
 slow_query_log = 1 
 slow-query-log-file=/path/of/the/log/file.log
 
 <div class="_1BN1N Kzi1t MoE_1 _2DJZN" style="z-index: 2; transform: translate(817px, 1679px);"><div class="_1HjH7"><div title="Protected by Grammarly" class="_3qe6h"> 

Step 3: Restart the Server

<div contenteditable="true" data-gramm_id="c3bc8287-b937-627b-8adf-548e4026c9ad" data-gramm="true" spellcheck="false" data-gramm_editor="true">Then Restart the MySQL server in xampp control panel.image loading..<div contenteditable="true" data-gramm_id="57b2be29-c5c5-eed0-e7f3-1168f5411376" data-gramm="true" spellcheck="false" data-gramm_editor="true">That's it, now slow_query_log should be enabled you can confirm it by running following command in the MySQL shell 
 
 show variables like '%slow%';<div class="_1BN1N Kzi1t BD-0J _7_mnr MoE_1 _2DJZN" style="z-index: 2; transform: translate(834px, 2283px);"><div class="_1HjH7"><div title="Protected by Grammarly" class="_3qe6h"> <div class="_1BN1N Kzi1t BD-0J _7_mnr MoE_1 _2DJZN" style="z-index: 2; transform: translate(834px, 1730px);"><div class="_1HjH7"><div title="Protected by Grammarly" class="_3qe6h"> <div class="_1BN1N Kzi1t BD-0J _7_mnr MoE_1 _2DJZN" style="z-index: 2; transform: translate(834px, 317px);"><div class="_1HjH7"><div title="Protected by Grammarly" class="_3qe6h"> 
Share:

5 views

0 0

Post a comment

comments

www.000webhost.com