MySQL Error Log summary, mysql Log Summary
MySQL error logs record severe warnings and error messages during MySQL operation, as well as detailed information about each MySQL startup and shutdown. The error log is usually named hostname. err. Hostname indicates the Host Name of the server.
The error log contains information indicating when mysqld was started and stopped and also any critical errors that occur while the server is running. if mysqld notices a table that needs to be automatically checked or retried red, it writes a message to the error log. on some operating systems, the error log contains a stack trace if mysqld exits abnormally. the trace can be used to determine where mysqld exited. see Section 24.5, "Debugging and Porting MySQL ".
View the location of the Error Log
By default, error logs are stored in the data directory. You can also run the following command to view them. For example, the following is my test service.
mysql> show variables like '%log_error%';
+---------------+------------------------------------------------------+
| Variable_name | Value |
+---------------+------------------------------------------------------+
| log_error | /home/WDPM/MysqlData/mysql/DB-Server.localdomain.err |
+---------------+------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
Modify the location of the Error Log
The information recorded in the error log can be defined through log-error and log-warnings. log_error indicates whether to enable the error log function and the storage location of the error log, log-warnings defines whether to include warning information in the error log. You can specify the log_error value when starting MySQL. As shown below
[root@DB-Server ~]# /etc/init.d/mysql start --log_error=/tmp/DB-Server.localdomain.err
Starting MySQL..........[ OK ]
[root@DB-Server ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.20-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show variables like '%log_error%';
+---------------+--------------------------------+
| Variable_name | Value |
+---------------+--------------------------------+
| log_error | /tmp/DB-Server.localdomain.err |
+---------------+--------------------------------+
1 row in set (0.00 sec)
If you close MySQL and restart MySQL, you will find that the value of log_error has changed to/home/WDPM/MysqlData/mysql/DB-Server.localdomain.err. That is to say, this setting is only valid for this time. If you need to modify it permanently, you must specify the value of the log_error parameter in my. cnf.
Can error logs be named at will? The answer is yes. For example, I added the log_error =/u02/mysql. err parameter to the/etc/my. cnf configuration file and restarted MySQL, as shown below:
If the log_error parameter is set in the configuration file and log_error is also set when MySQL is started, what is the priority? I tested and verified that the parameter priority of my. cnf is higher than that of log_error.
/Etc/init. d/mysql start log_error =/tmp/DB-Server.localdomain.err
Error Log archive backup
If the error log is not cleared or deleted, it will continue to grow. Before MySQL 5.5.7, you can use the mysqladmin-uroot-p flush-logs command to delete error logs. MySQL 5.5.7 and later, you can archive and back up error logs in the following ways.
shell> mv host_name.err host_name.err-old
shell> mysqladmin -u root -p flush-logs
shell> mv host_name.err-old backup-directory