≡ Menu

How to Check and Repair a MySQL Database Through Console SSH

mysql logoHere is step by step explanation on How to Check and Repair a MySQL Database Through Console SSH with Mysqlcheck and Myisamchk are similar in purpose, there are some essential differences. Mysqlcheck as well as Myisamchk can check, repair and analyze MyISAM tables. Mysqlcheck can also check InnoDB tables.

step 1: Log in as ‘root’ via SSH and:
step 2: Shows you if any need repair:

myisamchk --check /var/lib/mysql/*/*.MYI

step 3: Recover MySql Database
try ‘safe-recover’ first:

myisamchk --safe-recover /var/lib/mysql/*/*.MYI

and, if neither that nor this works:

myisamchk --recover /var/lib/mysql/*/*.MYI

Then use the ‘force’ flag:

myisamchk --recover --extend-check --force /var/lib/mysql/*/*.MYI

If those are not MyISAM tables try Mysqlcheck:

mysqlcheck --all-databases -r #repair databases
mysqlcheck --all-databases -a #analyze databases
mysqlcheck --all-databases -o #optimize databases

to repair one database:

mysqlcheck -ro database_name

to repair one table in database:

mysqlcheck -ro database_name table_name

ref: vps.net

{ 1 comment… add one }
  • shorf.com September 1, 2016, 7:21 am

    Got broken all databases suddenly , these tips helped me to fix them , thanks mate.

Leave a Comment

*