Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
How to Check, Recover & Repair MySQL Databases
UKBusinessLive
Join Date: Sep 2008
Posts: 1,637

Work like a donkey at work, love chillin on VB.org. Work Hard - Play Hard! - Try it you'll love it

Essex, United Kingdom
Show Printable Version Email this Page Subscription
UKBusinessLive UKBusinessLive is offline 01-02-2009, 10:00 PM

Looks Familiar??? No matter how much you manage your sever, at one stage in your dealings with MySQL Databases you will get errors, So what do you do ??

Code:
jtablesession::Store Failed
DB function failed with error number 145
Table './webkinzc_jo151/jos_session' is marked as crashed and should be repaired SQL=INSERT INTO `jos_session` ( `session_id`,`time`,`username`,`gid`,`guest`,`client_id` ) VALUES ( 'fd773853ae5aa0aca6aa7c22c79dcbbd','1230945305','','0','1','0' )
How to repair all MySQL Databases on a cPanel Server

There can be different reasons why one wants to repair a MySQL database. Database corruption maybe due to a lack of disk space or an unexpected server shutdown that caused the database to go bad. Queries that worked before suddenly stopped working and overall the database is not behaving anymore as expected. This post is not a full database troubleshooting guide, but rather give you a hand on doing a MySQL repair on all databases on a cPanel/WHM server (or any other server running MySQL).

The situation: Your server crashed hard and when it is back up the MySQL side of the house is not working anymore. You do your normal troubleshooting. If all other troubleshooting and verifications are done, you come to the conclusion that you will need to run a repair as the next step. A full database restore from a (hopefully existing) good database backup would be your last choice.

Repairing one MySQL database is fairly easy, but how do you do this for an entire server holding20, 30, 50 or over 100 databases? You will need SSH access as the root user to the server running MySQL. So, log in as the root user and then do the following to repair your MySQL databases:

Option #1

Check if you any need DB repair:
Code:
myisamchk --check /var/lib/mysql/*/*.MYI
Then try a 'safe-recover' as the first step:
Code:
myisamchk --safe-recover /var/lib/mysql/*/*.MYI
If the ?safe-recover? does not work, run a full recover:
Code:
myisamchk --recover /var/lib/mysql/*/*.MYI
Then use the 'force' flag to get things back to normal:
Code:
myisamchk --safe-recover --extend-check --force /var/lib/mysql/*/*.MYI
or:
Code:
myisamchk --recover --extend-check --force /var/lib/mysql/*/*.MYI


Option #2

Use the mysqlcheck tool to repair your databases.

Code:
mysqlcheck --all-databases -r #repair
Code:
mysqlcheck --all-databases -a #analyze
Code:
mysqlcheck --all-databases -o #optimize
Option #3

1) Through cPanel:

Log in to your cPanel and go to MySQL Databases. In the section Modify Databases, select a database from the drop-down box next to Repair DB: and then click the Repair DB button.

If the database engine used by your database supports repair (for example, MyISAM supports it), you will see a list of the repaired tables within the database.

If your database engine does not support repair (e.g. InnoDB database engine), you will get the following error message:

note : The storage engine for the table doesn't support repair

2) Through phpMyAdmin:

Open your phpMyAdmin tool and select the database whose tables you wish to repair.

A list with all the database's tables will appear. Tick the tables you wish to repair, or simply click [Check All] to select all tables.

Click the box [With selected:] and choose Repair table. This will execute the REPAIR TABLE SQL query on the selected tables and they will be repaired.

There you have it. By using one of these threee options you should be able to repair and recover your databases. Please be advised that you should backup critical databases before running any of the commands above. If something goes wrong you can revert back and try again.

In general the idea is to get people feeling confident enough to be able to work out a solution to a problem rather than worrying that they have a major serious issue.

Hope that helps
Reply With Quote
  #2  
Old 01-16-2009, 09:31 PM
NAZIA's Avatar
NAZIA NAZIA is offline
 
Join Date: Feb 2008
Location: Multan Pakistan
Posts: 322
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for sharing...
what does the
Quote:
Repair / Optimize Tables

OR
http://xyz.xyz /admincp/repair.php?do=list
Do in the admincp of the vbulletin?
Reply With Quote
  #3  
Old 01-18-2009, 12:42 AM
VK3MTR VK3MTR is offline
 
Join Date: Dec 2006
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks man, appreciate the advice.
Reply With Quote
  #4  
Old 01-19-2009, 05:26 AM
harisafp's Avatar
harisafp harisafp is offline
 
Join Date: Apr 2008
Location: hitech-forums.com
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Good for solutions ...
Thanks !!
Reply With Quote
  #5  
Old 04-04-2009, 03:10 AM
Jasem's Avatar
Jasem Jasem is offline
 
Join Date: Feb 2006
Location: www.menokia.com
Posts: 594
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

great work, thank you!
Reply With Quote
  #6  
Old 04-06-2009, 09:30 PM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think it would be better placed here=> https://vborg.vbsupport.ru/forumdisplay.php?f=188 it's no vb article..

also pls see this: https://vborg.vbsupport.ru/showthread.php?t=210032 but no feedback
Reply With Quote
  #7  
Old 07-26-2009, 03:32 PM
Golzarion's Avatar
Golzarion Golzarion is offline
 
Join Date: Jan 2008
Posts: 214
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks .Nice article .
Reply With Quote
  #8  
Old 06-30-2011, 12:00 PM
m2006's Avatar
m2006 m2006 is offline
 
Join Date: Jan 2006
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for advice
Reply With Quote
  #9  
Old 09-09-2011, 01:12 PM
itilm's Avatar
itilm itilm is offline
 
Join Date: Aug 2011
Location: Karachi
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

if forum not running & data not Restore so....???
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:32 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04260 seconds
  • Memory Usage 2,281KB
  • Queries Executed 22 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (9)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (2)post_thanks_box_bit
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete