Best way to repair MySQL from command line?

My Linode ran out of space and stuff started crashing. I'm not a DB admin, but worry instantly that something with the database might of hosed up.

What's the best way to repair a MySQL database on Debian 7.4? Anyone have any pointers? I'm not using phpMyadmin.

Thanks!!!

6 Replies

Usually if you're not getting any errors, then the database is ok.

Here's a slightly old check & optimize howto - be sure NOT to skip the first step (backup databases).

http://www.laurencegellert.com/2011/07/ … mysql-5-1/">http://www.laurencegellert.com/2011/07/mysql-maintenance-tasks-for-innodb-with-mysql-5-1/

Kyler,

Define "out of space". Memory or Disk.

Please provide the output from the "free -m" and "df" commands.

If the the df command shows /dev/xvda (or equivalent) at or near 100% you have a disk space issue. This is frequently caused by lack of log management. Check for excess log files in /var/log.

Dave

Hey, I'm sorry for the late reply. Thanks for chiming in.

I ran out of disk space. Basically, what happened in detail is my site was missing some information…it was just gone. I restarted Apache and that didn't work. So I rebooted the server via the reboot command from terminal.

When the server rebooted the entire site was down. So I signed in via SSH and tried to restart MySQL. That's when it told me it was out of disk space.

So, I got rid of some backup files that didn't need to be on there, and have also looked through the Logs folder.

Ran du -ah | sort -rn and no files were huge in size. The largest files were about 1000K, and there were only 200 of them.

I guess maybe my database is really large? Would anything have corrupted in this scenario? Site is up and everything seems fine.

When I am trying to identify the big disk space users, I use a repetitive brute force method:

Starting at /

sudo du -sk *

Follow any interesting paths. This can lead to large files and/or directories with lots of smaller files. You do, however, have to understand what you are looking at and do not do anything you will regret.

Dave

David / Vonskippy,

I got my space issues fixed, but now there's a problem with the database. The site is working fine, but when I try and backup the database with Backupbuddy it is halting on a db error.

So I used the link above from Vonskippy to check and analyze the database. Both fail, saying the same thing:

Error : Table 'oilygurusmain.og_wfNet404s' doesn't exist

Error : Table 'oilygurusmain.og_wfVulnScanners' doesn't exist

Nevermind….it was the WordFence plugin. Had to deactivate the plugin and let it remove tables.

Looks like I'm good - thanks guys!!!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct