时间:2022-12-06 01:23
1.首先,在命令行中执行命令启动MySQL服务;
Windows:net start mysql
Linux:service mysql start
2.MySQL服务启动后,在命令行中输入mysql的用户名和密码,登录到MySQL;
mysql -u root -p
3.登录到MySQL后,即可使用以下命令查询日志文件。
例:查看日志文件
mysql> show variables like ‘general_log_file’;
±-----------------±-----------------------------------+
| Variable_name | Value |
±-----------------±-----------------------------------+
| general_log_file | /usr/local/mysql/data/localhost.log |
±-----------------±-----------------------------------+
1 row in set (0.00 sec)
例:查看错误日志文件
mysql> show variables like ‘log_error’;
±--------------±-----------------------------------+
| Variable_name | Value |
±--------------±-----------------------------------+
| log_error | /usr/local/mysql/data/localhost.err |
±--------------±-----------------------------------+
1 row in set (0.00 sec)
例:查看慢查询日志文件
mysql> show variables like ‘slow_query_log_file’;
±--------------------±----------------------------------------+
| Variable_name | Value |
±--------------------±----------------------------------------+
| slow_query_log_file | /usr/local/mysql/data/localhost-slow.log |
±--------------------±----------------------------------------+
1 row in set (0.01 sec)