Here 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:
1 |
myisamchk --check /var/lib/mysql/*/*.MYI |
step 3: Recover MySql Database
try ‘safe-recover’ first:
1 |
myisamchk --safe-recover /var/lib/mysql/*/*.MYI |
and, if neither that nor this works:
1 |
myisamchk --recover /var/lib/mysql/*/*.MYI |
Then use the ‘force’ flag:
1 |
myisamchk --recover --extend-check --force /var/lib/mysql/*/*.MYI |
If those are not MyISAM tables try Mysqlcheck:
1 2 3 |
mysqlcheck --all-databases -r #repair databases mysqlcheck --all-databases -a #analyze databases mysqlcheck --all-databases -o #optimize databases |
to repair one database:
1 |
mysqlcheck -ro database_name |
to repair one table in database:
1 |
mysqlcheck -ro database_name table_name |
ref: vps.net
Got broken all databases suddenly , these tips helped me to fix them , thanks mate.