Posts tagged with ‘repair’

 

  • Archives

  • Categories

There are generally 2 ways of repairing MySQL tables using the command line. First is to use “mysqlcheck“, the other is to use “myisamchk” (only for MyISAM). This is more for my own information.

This has been tested on Ubuntu 9.10 with MySQL 5

mysqlcheck

This is how you can check if your database tables are fine:

mysqlcheck -uUsername -pSecret –all-databases

Change “Username” to your username and “Secret” to your password.

To repair them, use:

mysqlcheck -uUsername -pSecret –all-databases –auto-repair

This requires of your MySQL daemon to be running. If it isn’t running use this to start:

sudo /etc/init.d/mysql start

myisamchk

If you have trouble running ‘mysqlcheck’, you can consider using ‘myisamchk’ instead if your tables are MyISAM. This command can be performed without MySQL daemon running. This fixes the data in your file system directly and this has saved me once.

sudo myisamchk –max-record-length=1048576 -o -f /var/lib/mysql/db_name/table_name.MYI

Change “db_name” to your database name and “table_name” to the name of the table you wish to repair.

 

When you delete large portions for data from your MySQL table, the database becomes more fragmented. It is always a good idea to re-optimize your MySQL database especially if you have a lot of varying characters (VARCHAR). Here’s the command to optimize just one table:

OPTIMIZE TABLE foo

But I am looking for a more command line solution and here it is:

mysqlcheck -op database_name

The ‘o’ refers to optimize. And the ‘p’ is the option for password requirement. You’ll be prompted for the password.

If you’re logged in as user ‘john’ in your SSH, the MySQL username will be ‘john’. If that’s not what you want, use option ‘u’ like this:

mysqlcheck -op -u user_name database_name

And to optimize all databases:

mysqlcheck -op -u user_name –all-databases

You can also use option ‘r’ to repair.

Note that the optimization only works for MyISAM, InnoDB, and ARCHIVE tables.

 

Mr F.G. Superman has a hidden identity! He’s really Bicycle Repair Man.

Monty Python – Bicycle Repair Man

And yes, when bicycles are broken or menaced by international communism, bicycle repairman is ready.

 

Great news! The large hadron collider might not be back online till after 2010. Doomsday has once again been postponed:

LHC Might Not Be Back Online Until 2010 or Later

When the LHC first went down, it was believed that repairs could get the system up and running by April 2009. Then we saw repairs pushing the timeline back to summer 2009. But now, CERN has arrived at a fork in the road regarding LHC repairs.

Plan A is a quick and dirty fix, getting the particle accelerator online as quickly as possible (late summer 2009) at the cost of operating at lower power. In this scenario, 3 of 8 pressure relief-system segments are replaced (only the broken ones) with the other 5 getting upgraded at unsaid maintenance dates in the future.

As of right now, the team is moving ahead with Plan A in the interest of getting data as soon as possible. Since we have absolutely no way of knowing which course of action is best, we’ll just support whatever the crazy physics geniuses decide.

Sometimes I wonder if these research would after have any form of technological benefit eventually. I’m all for building strange spooky science stuff but it is with the hope that somehow it would bring us better laptop batteries and more advanced computer chips or something. I guess I am not too interested in big bang or whatever.

 

WordPress powered and Django inspired.
Love and elephants come after.
RSS: Posts and comments.