我在哪里可以找到 XAMPP 中的 MySQL 日志文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3638128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 17:03:37  来源:igfitidea点击:

Where can I find the MySQL log file in XAMPP

mysqlxampp

提问by q0987

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.

我使用 PHP 在 XAMPP 中访问 MySQL。我的问题是如果出现数据库错误,我可以在哪里找到 MySQL 日志文件。

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)

回答by Marc B

If you do

如果你这样做

SHOW VARIABLES LIKE '%log_file%';

it will show exactly where they're being written.

它将准确显示它们的写入位置。

回答by d.raev

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

接受的答案有点旧,对于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/).

第一个将启用日志记录(默认情况下可能关闭)
,第二个选择更新首选文件(默认在 C:/xampp/mysql/data/ 下)。

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

注意:在 Windows 8 上,您可能必须以管理员身份运行 SQL IDE 才能保存此命令。

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

注意2:您也可以在配置中设置它,转到path_to_xampp/mysql/并编辑my.ini
(如果它不存在,则从my-default.ini复制)并在那里添加设置:

[mysqld]

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

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

回答by Giuseppe

You can also try looking at localhost/phpmyadmin/ and click on the Variables tab.

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

回答by Saad

It's a *.err file.

这是一个 *.err 文件。

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

你会在这里找到它: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.

要正确跟踪您的错误,请使用 Notepad++ 打开它并启动 Mysql。您应该在文件末尾看到错误。

回答by aris

On mac, it's likely to be at:

在 mac 上,它可能位于:

/Applications/XAMPP/xamppfiles/var/mysql

/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.

如果那里有很多错误文件,请执行 ls -la 以查看哪个是最新且最有可能的。