I've got some problems with my database. I hope somebody can help me out.
Problem:
The database keeps crashing on startup. In my log i see a couple off these errors:
[ERROR] /usr/libexec/mysqld: Table '.tablename' is marked as crashed and should be repaired
Normally i would repair this table using PHPMyAdmin or SSH but is it possible to do this without the database running? (because when i start it it crashes and stops)
Or is there any other way to get this all working again? I've got a back up but i will lose some data. The table that is crashed contains cache data, so i could miss that.
Thank you!
Gr. Matthijs
UPDATE by RolandoMySQLDBA
- Please post contents of
/etc/my.cnf
- Is the DB Server bare metal machine or VM ?
- How much RAM does the server have ?
- Are all the tables InnoDB, MyISAM, or a mixture of both ?
- Is the OS Linux or Windows ?
Best Answer
I take it you are using REPAIR TABLE by hand.
I also take it your are doing an automatic table repair for MyISAM. (You have to remove or comment out the option of
my.cnf
to disable automatic MyISAM table repair).You can actually repair the table without using MySQL but mysqld cannot be accessing it. How?
You have to use the offline utility myisamchk
Suppose you have the following
mydb
mytable
The table files would be
/var/lib/mysql/mydb/mytable.MYD
/var/lib/mysql/mydb/mytable.MYI
You can repair it with something like this
Afterwards, you can either login to mysql and do this
or restart mysql
Give it a Try !!!
UPDATE 2014-01-08 15:46 EST
Based on the last comment
I would stronly recommend that you get more memory. Why ?
MyISAM caches index pages to the MyISAM key buffer. MyISAM does not cache data. The mysqld process defers all data caching to the OS. That can be a little dangerous for all open MyISAM tables in a low memory DB Server.
A MyISAM table keeps a count of the number of times a file handle has been open against it. When MySQL is down, a MyISAM table with a nonzero file handle count is considered crashed.
Although I provided the answer to the question in fixing a crashed a MyISAM table without mysqld running, you have a bigger problem with a 2GB VM. It should be more like 8GB. You should also run mysqltuner.pl against the VM by doing this:
You can then learn if /etc/my.cnf is underconfigured.