简体   繁体   中英

Where can I find the MySQL log file in XAMPP

I use PHP to access MySQL in XAMPP. My question is where I can find the MySQL log file if there is a DB error.

Also, can I change the default location/name of that log file?

Thank you

///// Based on the coments //////

mysql> show variables like '%log_file%';
+---------------------------+------------------------------------+
| Variable_name             | Value                              |
+---------------------------+------------------------------------+
| general_log_file          | C:/xampp/mysql/data/mysql.log      |
| innodb_log_file_size      | 5242880                            |
| innodb_log_files_in_group | 2                                  |
| slow_query_log_file       | C:/xampp/mysql/data/mysql-slow.log |
+---------------------------+------------------------------------+
4 rows in set (0.00 sec)

If you do

SHOW VARIABLES LIKE '%log_file%';

it will show exactly where they're being written.

The accepted answer is a bit old, for MySQL 5.1+

you may use the queries:

SET GLOBAL general_log = 'ON';
SET GLOBAL general_log_file = 'my_log.log';

First will enable loging (which may be off by default)
and the second select updates the preferred file (by default under C:/xampp/mysql/data/).

NOTE: On windows 8 you may have to run your SQL IDE as ADMINISTRATOR for this commands to get saved.

NOTE2: you can also set this in the config, go to path_to_xampp/mysql/ and edit my.ini
(copy from my-default.ini if it does not exists) and add the settings there:

[mysqld]

general_log = 'ON';
general_log_file = 'my_log.log';

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

It's a *.err file.

You will find it here : C:\\xampp\\mysql\\data

To trace you error correctly, open it with Notepad++ for example and Start Mysql. You Should see the error at the end of the file.

您也可以尝试查看 localhost/phpmyadmin/ 并单击变量选项卡。

On mac, it's likely to be at:

/Applications/XAMPP/xamppfiles/var/mysql

If there are a lot of error files there, do ls -la to see which one is most recent and most likely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM