Difference between revisions of "MySQL FAQs"

From Hostek.com Wiki
Jump to: navigation, search
(Created page with "==How do I see all running processes in MySQL?== #Open up a command prompt on your server #Log into MySQL with this command: <pre>mysql -u root -p</pre> #Enter your root MySQL...")
 
Line 6: Line 6:
  
 
MySQL will display a full list of running processes along with the state of the query and the SQL being ran at that time.
 
MySQL will display a full list of running processes along with the state of the query and the SQL being ran at that time.
 +
 +
==VPS - How do I log slow queries?==
 +
You can set the this options in the my.cnf/my.ini option files
 +
 +
<pre>
 +
log_slow_queries = 1
 +
slow_query_log_file = <some file name>
 +
</pre>
 +
 +
If your server is above 5.1.6 you can set the slow query log in the runtime itself. For which you have to execute these queries (as root).
 +
 +
<pre>
 +
set global log_slow_queries = 1;
 +
set global slow_query_log_file = <some file name>;
 +
</pre>
 +
  
 
[[Category:Databases-MySQL]]
 
[[Category:Databases-MySQL]]

Revision as of 19:42, 4 June 2013

How do I see all running processes in MySQL?

  1. Open up a command prompt on your server
  2. Log into MySQL with this command:
    mysql -u root -p
  3. Enter your root MySQL password when prompted
  4. Issue this command:
    SHOW FULL PROCESSLIST\G

MySQL will display a full list of running processes along with the state of the query and the SQL being ran at that time.

VPS - How do I log slow queries?

You can set the this options in the my.cnf/my.ini option files

log_slow_queries = 1
slow_query_log_file = <some file name>

If your server is above 5.1.6 you can set the slow query log in the runtime itself. For which you have to execute these queries (as root).

set global log_slow_queries = 1;
set global slow_query_log_file = <some file name>;