mysql:錯誤日誌log_error:

一、啓動錯誤日誌:
在不一樣的狀況下,錯誤日誌會記錄在不一樣的位置,若是沒有配置文件指定文件名,則默認爲hostname.err
在mysql5.6的RPM發佈的方式中,錯誤日誌被放在/var/log/mysqld.log
能夠經過my.cnf文件進行配置
[mysqld_safe]
log-error=/var/log/mysqld.log
二、查看錯誤日誌:
mysql錯誤日誌以文本形式存放的mysql

[root@localhost run]# echo > /var/log/mysqld.log 清空mysqld日誌文件
[root@localhost run]# cat /var/log/mysqld.log sql

[root@localhost run]#service myql stop --中止mysql服務
[root@localhost run]# mysqld_safe --skip-grant-tables & 跳過受權進入mysql
[1] 3221
[root@localhost run]# 160328 09:39:08 mysqld_safe Logging to '/var/log/mysqld.log'.
160328 09:39:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
160328 09:39:09 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended日誌

[1]+ Done mysqld_safe --skip-grant-tables
[root@localhost run]#
三、查看錯誤日誌:
[root@localhost run]# tail /var/log/mysqld.log
2016-03-28 09:39:09 3398 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
2016-03-28 09:39:09 3398 [ERROR] Can't start server: can't create PID file: No such file or directory
160328 09:39:09 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
[root@localhost run]# perror 2 --查看錯誤代碼
OS error code 2: No such file or directory/code

三、刪除錯誤日誌:
錯誤日誌可能會不斷的增加,由於有必要的週期性的維護:
推薦的刪除方法:
#echo > /var/log/mysqld.logserver

相關文章
相關標籤/搜索