mysql二進位記錄檔出錯導致mysql服務無法啟動,mysql二進位

來源:互聯網
上載者:User

mysql二進位記錄檔出錯導致mysql服務無法啟動,mysql二進位

今天開啟phpmyadmin發現連不上mysql資料庫,重啟mysql啟動不起來,查看日誌發現如下錯誤

<span style="font-family:SimSun;font-size:12px;">mysqld: File '.\mysql-bin.000370' not found (Errcode: 2)141120 13:23:13 [ERROR] Failed to open log (file '.\mysql-bin.000370', errno 2)141120 13:23:13 [ERROR] Could not open log file141120 13:23:13 [ERROR] Can't init tc log141120 13:23:13 [ERROR] Aborting</span>

進入mysql/data目錄下手動刪除mysql-bin.xxxxx相關的檔案或者進入mysql命令列執行RESET MASTER刪除全部日誌,重啟mysql。

查詢得知Mysql Data目錄產生的大量mysql-bin.xxxxx檔案是叫做MySQL Binary Log,主要有下面兩個作用:

  1、資料恢複。

  2、在主從伺服器上提高複製的可靠性。

這些日誌可以mysqlbinlog工具進行查看

#mysqlbinlog mysql-bin.xxxxx

如果不需要這些記錄檔的話,在my.ini中注釋掉以下兩行,就不會再產生二進位記錄檔了:
#log-bin=mysql-bin
#binlog_format=mixed

不注釋的話可以配置自動刪除的天數,在mysql設定檔中,找到[mysqld],加上以下語句:

expire_logs_days = 3

也可以直接使用mysql命令配置:mysql> SET GLOBAL expire_logs_days=1;

可以將二進位日誌自動刪除的天數設為3。不設定的話預設為0,表示不自動刪除。






相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.