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。我的问题是,如果有DB错误,哪里可以找到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)
4 个解决方案
#1
26
If you do
如果你做
SHOW VARIABLES LIKE '%log_file%';
it will show exactly where they're being written.
它会准确地显示它们写在哪里。
#2
5
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.ini if it does not exists) and add the settings there:
注意2:您还可以在配置中设置它,转到path_to_xampp/mysql/并编辑my。ini(从我的默认拷贝。i(如果不存在)并在其中添加设置:
[mysqld]
general_log = 'ON';
general_log_file = 'my_log.log';
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#3
1
It's a *.err file.
这是一个*。做错了文件。
You will find it here : C:\xampp\mysql\data
你会在这里找到它:C:\xampp\mysql\数据
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。您应该会看到文件末尾的错误。
#4
1
You can also try looking at localhost/phpmyadmin/ and click on the Variables tab.
您还可以尝试查看localhost/phpmyadmin/并单击Variables选项卡。
#1
26
If you do
如果你做
SHOW VARIABLES LIKE '%log_file%';
it will show exactly where they're being written.
它会准确地显示它们写在哪里。
#2
5
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.ini if it does not exists) and add the settings there:
注意2:您还可以在配置中设置它,转到path_to_xampp/mysql/并编辑my。ini(从我的默认拷贝。i(如果不存在)并在其中添加设置:
[mysqld]
general_log = 'ON';
general_log_file = 'my_log.log';
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#3
1
It's a *.err file.
这是一个*。做错了文件。
You will find it here : C:\xampp\mysql\data
你会在这里找到它:C:\xampp\mysql\数据
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。您应该会看到文件末尾的错误。
#4
1
You can also try looking at localhost/phpmyadmin/ and click on the Variables tab.
您还可以尝试查看localhost/phpmyadmin/并单击Variables选项卡。