zoukankan      html  css  js  c++  java
  • Mysql ERROR 145 (HY000) Table crashed

    Errors about the table:

    The cause behind the error

    Low disk space could be a reason for MySQL table being marked as “crashed”. When you have low space on your disk, some of the tables in the database may get crashed. It usually happens when you get space issues on the part of the hard disk where your database is stored.

    Often it gets difficult to identify the specific tables that are affected by the error. Before starting the repair process, thus, let us quickly take a look at how to identify the corrupted MySQL tables.

    Identifying crashed MySQL tables

    You can identify corrupted tables through certain expected and observable errors in the queries, for example:

    • Can’t find file tbl_name.MYI (Errcode: nnn)
    • Unexpected end of file
    • Got error from table handler
    • Record file is crashed
    • Can’t find file tablethatshouldbethere.MYI
    • tablethatwasworking.frm is locked against change
    • Got error ### from table handler.

    You can run perror to get more information about the error

    Recovering MySQL Crashed Tables

    MySQL server provides its own tool to diagnose crashed tables. This tool is known as myisamchk, and you can use it as shown below:

    # myisamchk -s /var/lib/mysql/*/*.MYI

    Running this command will list the crashed MySQL tables, with a message as follows:

    MyISAM-table '/var/lib/mysql/dbname/table_name.MYI' is marked as crashed and should be repaired.

    Other than diagnosis, the tool can also help you repair the damaged table. In most cases, the problem is solved by running the myisamchk command.

    #myisamchk -r /var/lib/mysql/dbname/table_name.MYI

    But if it doesn’t solve the problem, try stopping your web service, so that no new requests are generated, stop the MySQLd daemon itself and run the below-given command:

    #myisamchk -r --update-state /var/lib/mysql/dbname/table_name.MYI

    The “–update-state” switch tells MySQL to mark the indicated table as “checked.” Once this has been done, restart your MySQLd and web service, and MySQL will repair the crashed table. As a result, the error will be removed, and your database will be safely restored.

    Also, you can fixed this error by recovering database by using backup.

    Also, You can repair this table directly. 

     

  • 相关阅读:
    暑假N天乐【比赛篇】 —— 2019牛客暑期多校训练营(第二场)
    莫比乌斯反演入门解析
    暑假N天乐【比赛篇】 —— 2019牛客暑期多校训练营(第一场)
    暑假N天乐 —— 多重+分组背包及变形
    暑假N天乐 —— 完全背包及变形
    暑假N天乐【比赛篇】 —— 牛客假日团队赛6
    暑假N天乐 —— 01背包及变形
    离线线段树 SPOJ
    [Python]数据类型、常量、变量和运算符(未完待续)
    [Python]从哪里开始学习写代码(未完待续)
  • 原文地址:https://www.cnblogs.com/rusking/p/12374039.html
Copyright © 2011-2022 走看看