2

I logged in my server via SSH and committed a "repair table xxx" query on a MyISAM table with 34 million rows and 69GB of data. Unfortunately the SSH connection was lost. When I logged back in I found the mysql -u xxx -p session was gone by 'ps a'. The disk mount is now fully occupied and is not released. So I suppose a repair again would correct all this?

I want to use cron job to run this remotely rather than from SSH which can possibly be disconnected again. After finding this page:

http://dev.mysql.com/doc/refman/5.0/en/rebuilding-tables.html

I see it's possible to run repair table via command line like this:

mysqlcheck --repair --databases db_name ...

But how can I just --repair a specific table in the database db_name? Any other tips regarding how I can correct this mess would be much appreciated!

4
  • mysqlcheck has a --tables option. But I think that mysqlcheck --repair db_name table_name will try to repair only one table. See the mysqlcheck docs Jul 12 '14 at 12:38
  • 1
    And you can issue any command (so mysqlcheck as well) in the background and force it to continue running even if you logoff with nohup ..command... & Jul 12 '14 at 12:45
  • But before you do anything, check what happened with the last run (doublecheck from a new session inside MySQL that the previous repair has indeed stopped or finished or if it is still running) and check the mysql error log to see if there is anything there. Jul 12 '14 at 12:54
  • 3
    @kavoir.com Also screen and tmux are a sysadmin's best friends :-)
    – jynus
    Jul 12 '14 at 18:13
2

Using screen or tmux to handle this task will mean that if the SSH connection is lost the session will continue. When you log back in you will find the mysql -u xxx -p session is still active.

nohup works too but "screen and tmux are a sysadmin's best friends" as jynus commented.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.