Technology TidBits

Answers to various technical questions on php programming, mysql, linux, and many more categories.
25% off Hosting at HostGator.com:
Use Code techbits25



What causes mysql to give an error 145?

Last updated: 07/02/2009
This is a problem with a table or tables being corrupted.  An example error message is:

Can't open file: 'cc_pages.MYD'. (errno: 145)

which is returned when trying to query the table. 

To fix this, you can use the myisamchk utility.

Here's a sample session to fix this table:

[root]# myisamchk cc_pages.MYI
Checking MyISAM file: cc_pages.MYI
Data records:    1350   Deleted blocks:    1648
myisamchk: warning: Table is marked as crashed
myisamchk: warning: 38 clients is using or hasn't closed the table properly
- check file-size
- check key delete-chain
- check record delete-chain
myisamchk: error: Record at pos: 170312 is not remove-marked
myisamchk: error: record delete-link-chain corrupted
- check index reference
- check data record references index: 1
myisamchk: error: Found 1535 keys of 1350
- check record links
myisamchk: error: Record-count is not ok; is 1349         Should be: 1350
myisamchk: warning: Found       1649 deleted blocks       Should be: 1648
myisamchk: warning: Found       4208 parts                Should be: 4209 parts
MyISAM-table 'cc_pages.MYI' is corrupted
Fix it using switch "-r" or "-o"

[root]# myisamchk -r cc_pages.MYI
- recovering (with sort) MyISAM-table 'cc_pages.MYI'
Data records: 1350
- Fixing index 1
Data records: 1349

Also see: http://dev.mysql.com/doc/refman/5.0/en/repair.html

blog comments powered by Disqus
Have your own Tech-bit to contribute? Submit it here

Other questions in this category:
What causes an error 150 when loading data into a mysql database?
How can I display long records in mysql without wrapping?
How can I import data in mysql
How can I get mysql table definitions in my php script?
How can I execute commands on mysql using a php script?
How can I add a conditional statement in the field list of my sql statement?
How can I dump table definitions (with no data) using mysqldump?
How can I manipulate a table with a reserved word as a column name?
How can I find out table information in mysql?
How can I rename a field in a mysql table?
How can a change a user password in mysql?
How can I reset the auto_increment id field in my table?
How can I see the syntax used to create a table in mysql?
How can I delete or remove a field from a mysql table?
What does an error 'Got error 122 from storage engine' mean?
How can I run sql commands from a file or import tables from the mysqldump?
How can I create a CSV file from a query?
How can I dump selected records using mysqldump?
How can I sum a field in mySQL only if it contains a value?
How can I find out all the unique values stored in a specific field?
How can I give a custom name to a field in my SQL query?
How can I copy a table from one database to another?
How can I do a search and replace in a mysql table?
How can I load in a sql file using the mysql command line?
How can I setup a field to record the last update of a record in mysql?
I need a php function to put all rows from a mysql query into an array
How can I find old or expired records in a database?
What's an easy backup script for my mysql databases?
How can I load a mysql query into a hash in php?
How to match a mysql datetime field for a specific day
How can I total up the number of entries in a database table by month?
SQL basics
Why use Mysql?
How do I remove / delete a field from a table?
How can I get rid of strange characters in my database output?
Tuning your mysql database.
How can a rearrange or reorder the column order in my table?
How can I fix this error: Can't create/write to file '/tmp/#sql_1111.MYD' (Errcode: 17)?
How do I reset my mysql quota on a 1&1 shared account?
How can I figure out the next auto_increment value for my table?
How can I see how big each mysql table is?
How can I remove a primary key from my database table?
How can I restore part of a table from a mysqldump backup file?
How to use Mysql subqueries instead of a join
How can I re-order the fields in my mysql database?
How can I recreate all the users in my database to a new database?
How can I log slow queries in mysql?



Powered by KnowledgebasePublisher 1.1
Host Gator
Content provided by Roberts WebForge, Inc.