MySQL database crashing regularly with error 145 table marked as crashed and should be repaired

Posted on 2008-11-03
Last Modified: 2008-12-15
I have had this database running for about 3 years now and for the past few months I keep getting tables that are crashing.  They appear to be the same tables each time.  What are some causes for this to happen?  I have checked the server and it has not been shutting down or restarting other than when I install updates and restart it myself.  That has yet to cause a problem.  

At first this happened just once and awhile but now it seems to happen every week.  I have not been able to pinpoint anything going on when this happens.  Any ideas on what to look for would be greatlly appreciated.  

I have this running on a windows server 2003 box using apache server.

Also, if you know of any way I can use a script to check the database and fix it automatically that would be great since I am not always able to check on the database on the weekends.

Question by:grizzly_adams
    LVL 59

    Accepted Solution

    How many records do you have in the database and how frequently is it written too?

    I have seen this before on application for secure logging (auditing) which has a couple hundred million records and gets gets peaks of thousands of records in a very short period of time.  Occassionally will find the database crashed and have to run the REPAIR TABLE command but there is a myisamchk option that will repair as well that you could probably setup in a CRON/scheduled task.
    LVL 26

    Expert Comment

    Tell me which types of tables crashing(MyISAM,InnoDB)?

    If its MyISAM then you can add below statement in my.ini


    Pls check this more details

    Also can you post your MySQL error log contents...???????
    LVL 26

    Expert Comment

    perror utility reports that some tables are corrupted and need to be repaired..

    $perror 145
    MySQL error code 145: Table was marked as crashed and should be repaired

    Stop the mysqld server with mysqladmin shutdown, run myisamchk --silent --force */*.MYI from the data directory to check all MyISAM tables, and restart mysqld. This ensures that you are running from a clean state

    Also, take a look at here..

    Author Comment


    Here is what the error log contains:

    081104  2:20:46 [ERROR] Error writing file 'f:/apache2triad/mysql/logs/myaccess.log' (errno: 13)
    081104  9:15:33 [Warning] Aborted connection 5652 to db: 'revolve' user: 'revolve' host: 'localhost' (Got an error reading communication packets)

    The table has about 3.5 million rows and gets written to constantly.  The one that crashes the most frequently get about 100k entries per day.  The table are all MyISAM.  I will try out stopping the mysql server tonight when everyone quits using it so that I can run the myisamchk command on it.

    LVL 26

    Assisted Solution

    perror utility reports that error no:13 is something related to permission

    $perror 13
    OS error code  13:  Permission denied

    Pls can you check whether "f:/apache2triad/mysql/logs/myaccess.log" has proper read/write permissions??

    LVL 26

    Expert Comment

    Did you check this?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi ( had suggested a “sed” way, I actually shell …
    This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now