How to repair mysql database or tables of the database?



I usually use following command to repair all the tables of the databases of a user.

=========
[root@server /var/lib/mysql]#for i in `ll |grep bigchakr|awk '{print $9}' |cut -d/ -f1`; do for j in `mysql -e "use $i; show tables;"|grep -v -`; do mysql -e "use $i; repair table $j;"; done done;

=========

User : bigchakr, please replace this user. It'll repair all the tables of all the DB of that user.

You can use myisamchk command to repair the DB. Here is the comamnd :

========
[root@server /var/lib/mysql]# myisamchk -r /var/lib/mysql/bigchakr_content/*.MYI
========

Note : bigchakr_content is the name of the DB. You can use following command.

========
[root@server /var/lib/mysql]# for i in `ll |grep bigchakr|awk '{print $9}'`; do myisamchk -r $i/*.MYI ; done
========

I don't prefer myisamchk since sometime it doesn't give good results.
By : webhostingtalk.com



Related Posts:



Responses

0 Respones to "How to repair mysql database or tables of the database?"

Post a Comment

»Thank you for reading this article
If you have questions or comments, please leave a comment
»You can click on the Subscribe by email to subscribe comments of this post
»You can register directly link pictures, mp3, video on the comment form.
»You may use some HTML tags such
»Please post comments polite and typing accented Vietnamese if possible
»Thank the good faith comment

 

Categories

Recent Comments

Total Pageviews

Return to top of page ©Web Server Tips Tricks 2010 | Develop by Mr.PhanQuan .Powered by Blogger . All rights reserved.