I want to check the log in MySQL to see the queries that are being run by my application. How can I do this? I am using XAMPP and the directory to MySQL is C:\xampp\mysql.
我要检查MySQL中的日志,查看应用程序运行的查询。我该怎么做呢?我正在使用XAMPP,而MySQL的目录是C:\ XAMPP \ MySQL。
This is what I get when I do show variables like '%log%';
这是当我显示像'%log%'这样的变量时得到的结果;
mysql> show variables like '%log%';
+---------------------------------+------------------------------------+
| Variable_name | Value |
+---------------------------------+------------------------------------+
| back_log | 50 |
| binlog_cache_size | 32768 |
| binlog_format | STATEMENT |
| expire_logs_days | 0 |
| general_log | OFF |
| general_log_file | C:/xampp/mysql/data/mysql.log |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_buffer_size | 8388608 |
| innodb_log_file_size | 5242880 |
| innodb_log_files_in_group | 2 |
| innodb_log_group_home_dir | C:\xampp\mysql\data\ |
| innodb_mirrored_log_groups | 1 |
| log | OFF |
| log_bin | OFF |
| log_bin_trust_function_creators | OFF |
| log_bin_trust_routine_creators | OFF |
| log_error | C:\xampp\mysql\data\mysql.err |
| log_output | FILE |
| log_queries_not_using_indexes | OFF |
| log_slave_updates | OFF |
| log_slow_queries | OFF |
| log_warnings | 1 |
| max_binlog_cache_size | 4294963200 |
| max_binlog_size | 1073741824 |
| max_relay_log_size | 0 |
| relay_log | |
| relay_log_index | |
| relay_log_info_file | relay-log.info |
| relay_log_purge | ON |
| relay_log_space_limit | 0 |
| slow_query_log | OFF |
| slow_query_log_file | C:/xampp/mysql/data/mysql-slow.log |
| sql_log_bin | ON |
| sql_log_off | OFF |
| sql_log_update | ON |
| sync_binlog | 0 |
+---------------------------------+------------------------------------+
37 rows in set (0.00 sec)
5 个解决方案
#1
29
Enable general query log by the following query in mysql command line
在mysql命令行中使用以下查询启用通用查询日志。
SET GLOBAL general_log = 'ON';
Now open C:/xampp/mysql/data/mysql.log
and check query log
现在打开C:/ xampp / mysql /数据/ mysql。日志和检查查询日志。
If it fails, open your my.cnf
file. For windows its my.ini
file and enable it there. Just make sure its in the [mysqld]
section
如果失败,打开您的my.cnf文件。我对windows。ini文件并启用它。只要确保它在[mysqld]部分。
[mysqld]
general_log = 1
Note: In xampp my.ini
file can be either found in xampp\mysql
or in c:\windows
directory
注意:在xampp。ini文件可以在xampp\mysql中找到,也可以在c:\windows目录中找到。
#3
1
Its given on OFFICIAL MYSQL website.
它是在官方MYSQL网站上发布的。
SET GLOBAL general_log = 'ON';
You can also use custom path:
您也可以使用自定义路径:
[mysqld]
# Set Slow Query Log
long_query_time = 1
slow_query_log = 1
slow_query_log_file = "C:/slowquery.log"
#Set General Log
log = "C:/genquery.log"
#4
0
Seems like the general query log is the file that you need. A good introduction to this is at http://dev.mysql.com/doc/refman/5.1/en/query-log.html
看起来一般的查询日志是您需要的文件。这篇文章的一个很好的介绍是http://dev.mysql.com/doc/refman/5.1/en/querylog.html。
#5
0
For me, general_log didn't worked. But adding this to my.ini worked
对我来说,general_log没有起作用。把这个加到我的。ini工作
[mysqld]
log-output=FILE
slow_query_log = 1
slow_query_log_file = "d:/temp/developer.log"
#1
29
Enable general query log by the following query in mysql command line
在mysql命令行中使用以下查询启用通用查询日志。
SET GLOBAL general_log = 'ON';
Now open C:/xampp/mysql/data/mysql.log
and check query log
现在打开C:/ xampp / mysql /数据/ mysql。日志和检查查询日志。
If it fails, open your my.cnf
file. For windows its my.ini
file and enable it there. Just make sure its in the [mysqld]
section
如果失败,打开您的my.cnf文件。我对windows。ini文件并启用它。只要确保它在[mysqld]部分。
[mysqld]
general_log = 1
Note: In xampp my.ini
file can be either found in xampp\mysql
or in c:\windows
directory
注意:在xampp。ini文件可以在xampp\mysql中找到,也可以在c:\windows目录中找到。
#2
#3
1
Its given on OFFICIAL MYSQL website.
它是在官方MYSQL网站上发布的。
SET GLOBAL general_log = 'ON';
You can also use custom path:
您也可以使用自定义路径:
[mysqld]
# Set Slow Query Log
long_query_time = 1
slow_query_log = 1
slow_query_log_file = "C:/slowquery.log"
#Set General Log
log = "C:/genquery.log"
#4
0
Seems like the general query log is the file that you need. A good introduction to this is at http://dev.mysql.com/doc/refman/5.1/en/query-log.html
看起来一般的查询日志是您需要的文件。这篇文章的一个很好的介绍是http://dev.mysql.com/doc/refman/5.1/en/querylog.html。
#5
0
For me, general_log didn't worked. But adding this to my.ini worked
对我来说,general_log没有起作用。把这个加到我的。ini工作
[mysqld]
log-output=FILE
slow_query_log = 1
slow_query_log_file = "d:/temp/developer.log"