Home >Database >Mysql Tutorial >Where is the log file in mysql
In mysql, log files are generally stored in the "/var/log/" directory; you can use the "show master status" statement to view the current log file, or you can modify the mysqld log in the configuration file related content to modify the location where the log file is stored.
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
Log files mainly include error log files, binary log files, slow query log files, query log files, redo log files, etc.
MySQL logs are generally saved in the /var/log/ directory, but you need to look at the specific configuration file to determine. The specific method is as follows:
1. First log in to mysql: >mysql -u root -p
2. Then check whether the log is enabled mysql>show variables like 'log_%';
3. Check the current log mysql> show master status;
4. You need Known mysql log types: Error log: -log-err
Query log: -log
Slow query log: -log- slow-queries
Update log: -log-update
Binary log: -log-bin
5. Modify the configuration /etc/my.cnf (the following is the log file storage location) [mysqld]
log=/var/log/mysqld_common.log log-error=/var/log/mysqld_err.log log-bin=/var/log/mysqld_bin.bin
Expand knowledge:
Below This article gives a detailed introduction to mssql log files. If you are interested in mysql log files, you may wish to take a look.
1. Error Log Error Log
The error log records all serious warnings and error messages during the operation of mysql server, as well as detailed information about each startup and shutdown of mysql.
To enable the method, add the --log-error option when starting mysql. The error log is placed in the data directory by default and is named hostname.err. However, you can use the command --log-error[=file_name] to modify the storage directory and file name.
Sometimes, you want to back up the error log and restart recording. Use the flush logs command to backup the file ending in .old.
2. Binary log: Binary Log&Binary Log Index
is often referred to as binlog, which is one of the most important logs in mysql. After turning on the logging function through --log-bin[=file_name], mysql will record all queries that modify database data into the log file in binary form, including the execution time and resources consumed by each query. , and related transaction information. If file_name is not specified, it will be recorded as mysql-bin.**** in the data directory.
Binlog also has some other additional option parameters:
--max_binlog_size sets the maximum storage limit of binlog. When the log reaches this limit, a file will be re-created. Record.
--binlog-do-db=db_name parameter tells mysql to only log binlog to a certain database
--binlog-ignore-db The =db_name parameter tells mysql to ignore binlog records for a certain database
3. Update log: update log
Not supported after mysql5.0, similar to binlog, but not Recorded in binary form, it is a simple text format record
4. Query log: query log
Query log records all queries in mysql, which can be opened through --log[=file_name] Since this log records all queries, it is large in size and has a great impact on performance after being turned on. This function is only turned on briefly when tracking some special query performance issues. The default file name is hostname.log.
5. Slow query log: slow query log
Use --log-slow-queries[=file_name] to turn on this function and set the recording location and file name. The default file name is: hostname -slow.log, the default directory is also the data directory.
6.InnoDB’s online REDO log: InnoDB REDO Log
The REDO log records all physical changes and transaction information made by InnoDB. Through REDO logs and UNDO information, InnoDB ensures Transaction security under all circumstances. InnoDB's REDO log is also stored in the data directory by default. You can change the storage location of the log through innodb_log_group_home_dir. Set the number of logs through innodb_log_files_in_group.
How to modify the location of the MYSQL database log file?
I believe everyone knows a lot about MySQL log files. MySQL log files are generally located at:/var/log/mysqld.log. The following will teach you how to modify the location of the MySQL log file for your reference.
Today I need to change the location of the MySQL log file, but I found that it cannot be changed in /etc/my.cnf.
Later I discovered that the MySQL log bit is specified:
Recommended learning: mysql video tutorial
The above is the detailed content of Where is the log file in mysql. For more information, please follow other related articles on the PHP Chinese website!