Home >Database >Mysql Tutorial >How to enable error log in mysql

How to enable error log in mysql

青灯夜游
青灯夜游Original
2022-06-16 15:48:163729browse

Opening method: 1. Open the "my.ini" configuration file and search for "[mysqld]"; 3. Under the "[mysqld]" group, add the "log_error" item and set the log storage location, syntax "log-error=dir/{filename}", where the "dir" parameter specifies the storage path of the error log, and the "filename" parameter specifies the file name of the error log. If the parameter after "log_error" is omitted, the file name defaults to the host name and is stored in the Data directory.

How to enable error log in mysql

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

The Error Log is the most commonly used log in MySQL. It mainly records information during the startup and stop process of the MySQL server, failures and exceptions that occur during the operation of the server, etc.

Mysql method to enable error log

In MySQL, open the my.ini configuration file and add the log_error option to the [mysqld] group , the form is as follows:

[mysqld]
log-error=dir/{filename}

Among them, the dir parameter specifies the storage path of the error log; the filename parameter specifies the file name of the error log; when the parameter is omitted, the file name defaults to the host name and is stored in the Data directory. .

After restarting the MySQL service, the parameters will take effect. You can see the filename.err file under the specified path. If filename is not specified, the error log will directly default to hostname.err.

For example, our log_error option configuration:

How to enable error log in mysql

How to enable error log in mysql

Note: Not all recorded in the error log are Error information, such as how MySQL starts InnoDB's table space file, how to initialize its own storage engine, etc., are also recorded in the error log file.

Note:

In the MySQL database, the error log function is enabled by default. Typically, the error log is stored in the data folder of the MySQL database, usually with the name hostname.err. Among them, hostname represents the host name of the MySQL server.

In the MySQL configuration file, the information recorded in the error log can be defined through log-error and log-warnings. Among them, log-err defines whether to enable the error log function and the storage location of the error log. log- warnings defines whether warning information is also logged to the error log.

[Related recommendations: mysql video tutorial]

The above is the detailed content of How to enable error log in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn