2012-03-26 10 views
19

Voglio controllare il log in MySQL per vedere le query che vengono eseguite dalla mia applicazione. Come posso fare questo? Sto usando XAMPP e la directory di MySQL è C: \ xampp \ mysql.Come posso avviare e controllare il mio log MySQL?

Questo è ciò che ottengo quando faccio show variables like '%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) 
+0

E 'questo quello che stai cercando? http://stackoverflow.com/questions/9871718/how-can-i-start-and-check-my-mysql-log –

+0

Il tuo file di registro generale è qui: 'C: /xampp/mysql/data/mysql.log ', il file di log degli errori è qui:' C: \ xampp \ mysql \ data \ mysql.err' e penso che i log delle query siano qui: 'C:/xampp/mysql/data/mysql-slow.log'. – hjpotter92

risposta

28

Abilita log delle query generale con la seguente query in MySQL a riga di comando

SET GLOBAL general_log = 'ON'; 

Ora aperto C:/xampp/mysql/data/mysql.log e controllare log delle query

Se fallisce, aprire il file my.cnf. Per Windows è il suo file my.ini e abilitarlo lì. Basta assicurarsi che il suo nella sezione [mysqld]

[mysqld] 
general_log    = 1 

Nota: in XAMPP my.ini file può essere trovato in xampp\mysql o in c:\windows directory

+0

Dice: ERRORE 1227 (42000): accesso negato; è necessario il privilegio SUPER per questa operazione su –

+0

@JohnathanAu è necessario essere 'root' (utente mysql' root') per fare ciò. –

+1

Ehi, intendi root per PC? Come lo faccio? –

0

Per me, general_log non ha funzionato. Ma aggiungendo questo a my.ini ha funzionato

[mysqld] 
log-output=FILE 
slow_query_log = 1 
slow_query_log_file = "d:/temp/developer.log" 
0

Viene fornito sul sito Web UFFICIALE di MYSQL.

SET GLOBAL general_log = 'ON'; 

È inoltre possibile utilizzare percorso personalizzato:

[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" 
Problemi correlati