´ËÎĵµÊÇһλ¸ßÊÖͬÊÂHeweiµÄÔ´´Êµ¼ù×ܽá,¹ý³ÌÕæÊǾ«²Ê,×îºóÐÞ¸´Ëð»µÊý¾Ý¿âÈ¡µÃÔ²ÂúЧ¹û,ÖµµÃÊղصÄһƪºÃÎÄÕÂ
mysqlÊý¾Ý¿âÏÂËð»µÊý¾ÝµÄ»Ö¸´²Ù×÷Æä¹ý³Ì×ܽá
(´ËÎĵµÊÇһλ¸ßÊÖͬÊÂHeweiµÄÔ´´Êµ¼ù×ܽá,¹ý³ÌÕæÊǾ«²Ê,×îºóÐÞ¸´Ëð»µÊý¾Ý¿âÈ¡µÃÔ²ÂúЧ¹û,ÖµµÃÊղصÄһƪºÃÎÄÕÂ)
Ç°¼¸ÌìÒòΪmysqlÊý¾Ý¿â²¿·ÖÊý¾ÝËð»µÔÒò£¬ÎÒ³¢ÊÔÁËÏ»ָ´Êý¾Ý£¬Ö®ºóÕûÀíÒÔÏÂÎĵµ£¬¹©¸÷λ²Î¿¼,
ÒÔ±¸¸÷λͬÊÂÒÔºóÈçÓÐÀàËÆÎÊÌ⣬¿ÉÒÔÉÙ×ßЩÍä·,¾¡¿ì½â¾öÎÊÌâ¡£
»·¾³£ºwindows2003
Êý¾Ý¿â:mysql
Ëð»µÊý¾ÝÎļþÃû:function_products
½«Êý¾Ý¿âÄÚÈÝÎïÀíÎļþÖ±½Óµ¼Èëµ½mysql\dataÏ£¬Ã¿Ö»±í¸÷3¸öÎļþ£¬ÒÀ´Î·Ö±ðΪ£º.frm .MYD .MYI
Ê×ÏÈÎÒµÚÒ»Ïëµ½µÄÊÇÈ¥ÍøÉÏËÑË÷£¬Ñ°ÕÒÀàËƵŤ¾ß£¬ÊÔͼͨ¹ý¹¤¾ßÀ´»Ö¸´ÒÑË𻵵ÄÎļþ£¬ÓÚÊÇÎÒÔÚGOOGLEÉϲéÕÒ£¬
ÕÒµ½Ò»¿îÃûΪMySQLRecoveryµÄ¹¤¾ß£¬°²×°ºóÎÒÓÃÆä½øÐлָ´£¬Ö»¿ÉϧЧ¹ûÌ«²»ÀíÏ룬¼¸Ê®M´óµÄÊý¾ÝÎļþ£¬»Ö¸´
Ö®ºóËüÌáʾÎÒ¾¹È»Ö»Óм¸Ê®K£¬ÁîÎÒÍÂѪ...
ÎÒÓÖÏëµ½ÁËmysqlÏÂÓ¦ÓÐ×Ô¼º±¾ÉíµÄÐÞ¸´³ÌÐòµÈ£¬ÓÚÊÇÏëͨ¹ýÆäÀ´½øÐлָ´£¬ÐÄÏëÓ¦²»»áÌ«²î¾¢°É£¬ÔÚÍøÉϲéÕÒÁË
×ÊÁÏ£¬Ìáʾ£º
ÓÉÓÚÁÙʱ¶Ïµç£¬Ê¹ÓÃkill -9ÖÐÖ¹MySQL·þÎñ½ø³Ì£¬»òÕßÊÇmysqlÕýÔÚ¸ßËÙÔËתʱ½øÐÐÇ¿ÖƱ¸·Ý²Ù×÷ʱµÈ£¬
ËùÓеÄÕâЩ¶¼¿ÉÄÜ»á»Ù»µMySQLµÄÊý¾ÝÎļþ¡£Èç¹ûÔÚ±»¸ÉÈÅʱ£¬·þÎñÕýÔڸıäÎļþ£¬Îļþ¿ÉÄÜ»áÁôÏ´íÎóµÄ
»ò²»Ò»ÖµÄ״̬¡£ÒòΪÕâÑùµÄ»Ù»µÓÐʱÊDz»ÈÝÒ×±»·¢Ïֵģ¬µ±Äã·¢ÏÖÕâ¸ö´íÎóʱ¿ÉÄÜÊǺܾÃÒÔºóµÄÊÂÁË¡£
ÓÚÊÇ£¬µ±Äã·¢ÏÖÕâ¸öÎÊÌâʱ£¬Ò²ÐíËùÓеı¸·Ý¶¼ÓÐͬÑùµÄ´íÎó¡£
ÎÒÏëÎÒÏÖÔÚÅöµ½µÄÎÊÌâ¿ÉÄÜÊÇÕâ¸öÎÊÌ⣬ÒòΪ±¸·ÝµÄÊý¾ÝÒ²ÊÇÓв¿·ÖË𻵵ÄÊý¾Ý£¬ËùÒÔµ¼Ö²»ÄÜÍêÈ«ÔËÐУ¬
Òâʶµ½myisamchk³ÌÐò¶ÔÓÃÀ´¼ì²éºÍÐ޸ĵÄMySQLÊý¾ÝÎļþµÄ·ÃÎÊÓ¦¸ÃÊÇΨһµÄ¡£Èç¹ûMySQL·þÎñÕýÔÚʹÓÃ
ijһÎļþ£¬²¢¶ÔmyisamchkÕýÔÚ¼ì²éµÄÎļþ½øÐÐÐ޸ģ¬myisamchk»áÎóÒÔΪ·¢ÉúÁË´íÎ󣬲¢»áÊÔͼ½øÐÐÐÞ¸´--
Õ⽫µ¼ÖÂMySQL·þÎñµÄ±ÀÀ££¡ÕâÑù£¬Òª±ÜÃâÕâÖÖÇé¿öµÄ·¢Éú£¬Í¨³£ÎÒÃÇÐèÒªÔÚ¹¤×÷ʱ¹Ø±ÕMySQL·þÎñ¡£×÷ΪѡÔñ£¬
ÄãÒ²¿ÉÒÔÔÝʱ¹Ø±Õ·þÎñÒÔÖÆ×÷Ò»¸öÎļþµÄ¿½±´£¬È»ºóÔÚÕâ¸ö¿½±´ÉϹ¤×÷¡£µ±Äã×öÍêÁËÒÔºó£¬ÖØйرշþÎñ²¢Ê¹
ÓÃеÄÎļþÈ¡´úÔÀ´µÄÎļþ(Ò²ÐíÄ㻹ÐèҪʹÓÃÆÚ¼äµÄ±ä¸üÈÕÖ¾)¡£
MySQLÊý¾ÝĿ¼²»ÊÇÌ«ÄÑÀí½âµÄ¡£Ã¿Ò»¸öÊý¾Ý¿â¶ÔÓ¦Ò»¸ö×ÓĿ¼£¬Ã¿¸ö×ÓĿ¼Öаüº¬Á˶ÔÓ¦ÓÚÕâ¸öÊý¾Ý¿âÖеÄ
Êý¾Ý±íµÄÎļþ¡£Ã¿Ò»¸öÊý¾Ý±í¶ÔÓ¦Èý¸öÎļþ£¬ËüÃǺͱíÃûÏàͬ£¬µ«ÊǾßÓв»Í¬µÄÀ©Õ¹Ãû¡£tblName.frmÎļþÊÇ
±íµÄ¶¨Ò壬Ëü±£´æÁ˱íÖаüº¬µÄÊý¾ÝÁеÄÄÚÈݺÍÀàÐÍ¡£tblName.MYDÎļþ°üº¬Á˱íÖеÄÊý¾Ý¡£tblName.MYIÎļþ
°üº¬Á˱íµÄË÷Òý(ÀýÈ磬Ëü¿ÉÄÜ°üº¬lookup±íÒÔ°ïÖúÌá¸ß¶Ô±íµÄÖ÷¼üÁеIJéѯ)¡£
Òª¼ì²éÒ»¸ö±íµÄ´íÎó£¬Ö»ÐèÒªÔËÐÐmyisamchk(ÔÚMySQLµÄbinĿ¼ÏÂ)²¢ÌṩÎļþµÄλÖúͱíÃû£¬»òÕßÊDZíµÄË÷ÒýÎļþÃû£º
% myisamchk /usr/local/mysql/var/dbName/tblName
% myisamchk /usr/local/mysql/var/dbName/tblName.MYI
ÉÏÃæµÄÁ½¸öÃüÁ¿ÉÒÔÖ´ÐжÔÖ¸¶¨±íµÄ¼ì²é¡£Òª¼ì²éÊý¾Ý¿âÖÐËùÓÐµÄ±í£¬¿ÉÒÔʹÓÃͨÅä·û£º
% myisamchk /usr/local/mysql/var/dbName/*.MYI
Òª¼ì²éËùÓÐÊý¾Ý¿âÖеÄËùÓÐ±í£¬¿ÉÒÔʹÓÃÁ½¸öͨÅä·û£º
% myisamchk /usr/local/mysql/var/*/*.MYI
Èç¹û²»´øÈκÎÑ¡Ïmyisamchk½«¶Ô±íÎļþÖ´ÐÐÆÕͨµÄ¼ì²é¡£Èç¹ûÄã¶ÔÒ»¸ö±íÓл³ÒÉ£¬µ«ÊÇÆÕͨµÄ¼ì²é²»ÄÜ·¢ÏÖÈκδíÎó£¬Äã¿ÉÒÔÖ´Ðиü³¹µ×µÄ¼ì²é(µ«ÊÇÒ²¸üÂý£¡)£¬ÕâÐèҪʹÓÃ--extend-checkÑ¡Ï
% myisamchk --extend-check /path/to/tblName
¶Ô´íÎóµÄ¼ì²éÊÇûÓÐÆÆ»µÐԵģ¬ÕâÒâζ×ÅÄã²»±Øµ£ÐÄÖ´ÐжÔÄãµÄÊý¾ÝÎļþµÄ¼ì²é»áʹÒѾ´æÔÚµÄÎÊÌâ±äµÃ¸üÔã¡£ÁíÒ»·½Ã棬ÐÞ¸´Ñ¡ÏËäȻͨ³£Ò²ÊÇ°²È«µÄ£¬µ«ÊÇËü¶ÔÄãµÄÊý¾ÝÎļþµÄ¸ü¸ÄÊÇÎÞ·¨³·ÏûµÄ¡£ÒòΪÕâ¸öÔÒò£¬ÎÒÃÇÇ¿ÁÒÍƼöÄãÊÔͼÐÞ¸´Ò»¸ö±»ÆÆ»µµÄ±íÎļþʱÊ×ÏÈ×ö¸ö±¸·Ý£¬²¢È·±£ÔÚÖÆ×÷Õâ¸ö±¸·Ý֮ǰÄãµÄMySQL·þÎñÊǹرյġ£
ÎÒÔÚwin2003ÏÂͨ¹ýÃüÁîÌáʾ·û£¬ÊäÈ룺
×¢£º´ËΪ¼Ç¼ÎÒµ±Ê±²Ù×÷µÄÈ«²¿¹ý³Ì
D:\Documents and Settings\Administrator>c:
C:\>cd mysql
C:\mysql>cd data
C:\mysql\data>cd hw_enterprice
C:\mysql\data\hw_enterprice>myisamchk function_products.frm
'myisamchk' ²»ÊÇÄÚ²¿»òÍⲿÃüÁҲ²»ÊÇ¿ÉÔËÐеijÌÐò
»òÅú´¦ÀíÎļþ¡£
C:\mysql\data\hw_enterprice>cd\
C:\>cd mysql
C:\mysql>cd bin
×¢£º²é¿´myisamchkµÄ°ïÖúÐÅÏ¢
C:\mysql\bin>myisamchk
myisamchk Ver 2.6 for Win95/Win98 at i32
By Monty, for your professional use
This software comes with NO WARRANTY: see the PUBLIC for details.
Description, check and repair of ISAM tables.
Used without options all tables on the command will be checked for errors
Usage: myisamchk [OPTIONS] tables[.MYI]
Global options:
-#, --debug=... Output debug log. Often this is 'd:t:o,filename'
-?, --help Display this help and exit.
-O, --set-variable var=option
Change the value of a variable. Please note that
this option is deprecated; you can set variables
directly with '--variable-name=value'.
-t, --tmpdir=path Path for temporary files
-s, --silent Only print errors. One can use two -s to make
myisamchk very silent
-v, --verbose Print more information. This can be used with
--description and --check. Use many -v for more verbosity!
-V, --version Print version and exit.
-w, --wait Wait if table is locked.
Check options (check is the default action for myisamchk):
-c, --check Check table for errors
-e, --extend-check Check the table VERY throughly. Only use this in
extreme cases as myisamchk should normally be able to
find out if the table is ok even without this switch
-F, --fast Check only tables that haven't been closed properly
-C, --check-only-changed
Check only tables that have changed since last check
-f, --force Restart with '-r' if there are any errors in the table.
States will be updated as with '--update-state'
-i, --information Print statistics information about table that is checked
-m, --medium-check Faster than extend-check, but only finds 99.99% of
all errors. Should be good enough for most cases
-U --update-state Mark tables as crashed if you find any errors
-T, --read-only Don't mark table as checked
Repair options (When using '-r' or '-o')
-B, --backup Make a backup of the .MYD file as 'filename-time.BAK'
--correct-checksum Correct checksum information for table.
-D, --data-file-length=# Max length of data file (when recreating data
file when it's full)
-e, --extend-check Try to recover every possible row from the data file
Normally this will also find a lot of garbage rows;
Don't use this option if you are not totally desperate.
-f, --force Overwrite old temporary files.
-k, --keys-used=# Tell MyISAM to update only some specific keys. # is a
bit mask of which keys to use. This can be used to
get faster inserts!
-r, --recover Can fix almost anything except unique keys that aren't
unique.
-n, --sort-recover Forces recovering with sorting even if the temporary
file would be very big.
-p, --parallel-recover
Uses the same technique as '-r' and '-n', but creates
all the keys in parallel, in different threads.
THIS IS ALPHA CODE. USE AT YOUR OWN RISK!
-o, --safe-recover Uses old recovery method; Slower than '-r' but can
handle a couple of cases where '-r' reports that it
can't fix the data file.
--character-sets-dir=...
Directory where character sets are
--set-character-set=name
Change the character set used by the index
-q, --quick Faster repair by not modifying the data file.
One can give a second '-q' to force myisamchk to
modify the original datafile in case of duplicate keys
-u, --unpack Unpack file packed with myisampack.
Other actions:
-a, --analyze Analyze distribution of keys. Will make some joins in
MySQL faster. You can check the calculated distribution
by using '--description --verbose table_name'.
-d, --description Prints some information about table.
-A, --set-auto-increment[=value]
Force auto_increment to start at this or higher value
If no value is given, then sets the next auto_increment
value to the highest used value for the auto key + 1.
-S, --sort-index Sort index blocks. This speeds up 'read-next' in
applications
-R, --sort-records=#
Sort records according to an index. This makes your
data much more localized and may speed up things
C:\mysql\bin>myisamchk c:\mysql\data\hw_enterprice\function_products.frm
myisamchk: error: 'c:\mysql\data\hw_enterprice\function_products.frm' is not a M
yISAM-table
C:\mysql\bin>myisamchk c:\mysql\data\hw_enterprice\function_products.myi
Checking MyISAM file: c:\mysql\data\hw_enterprice\function_products.myi
Data records: 85207 Deleted blocks: 39
myisamchk: warning: Table is marked as crashed
myisamchk: warning: 1 clients is using or hasn't closed the table properly
- check file-size
- check key delete-chain
- check record delete-chain
myisamchk: error: record delete-link-chain corrupted
- check index reference
- check data record references index: 1
- check data record references index: 2
- check data record references index: 3
- check record links
myisamchk: error: Wrong bytesec: 0-195-171 at linkstart: 841908
MyISAM-table 'c:\mysql\data\hw_enterprice\function_products.myi' is corrupted
Fix it using switch "-r" or "-o"
¼ÌÐø½øÐвÙ×÷£º
C:\mysql\bin>myisamchk --recover --quick c:\mysql\data\hw_enterprice\function_p
roducts.myi
- check key delete-chain
- check record delete-chain
myisamchk: error: record delete-link-chain corrupted
myisamchk: error: Quick-recover aborted; Run recovery without switch 'q'
Updating MyISAM file: c:\mysql\data\hw_enterprice\function_products.myi
MyISAM-table 'c:\mysql\data\hw_enterprice\function_products.myi' is not fixed be
cause of errors
Try fixing it by using the --safe-recover (-o) or the --force (-f) option
ϵͳÌáʾÎÒʹÓÃ--safe-recover (-o) or the --force (-f) option½øÐÐÐÞ¸´²Ù×÷£¬ÓÚÊÇ
C:\mysql\bin>myisamchk --safe-recover c:\mysql\data\hw_enterprice\function_prod
ucts.myi
- recovering (with keycache) MyISAM-table 'c:\mysql\data\hw_enterprice\function_
products.myi'
Data records: 85207
Wrong bytesec: 0-195-171 at 841908; Skipped
Data records: 85215
½«ÐÞ¸´ºóµÄÎïÀíÎļþ¸´ÖƵ½mysql\dataÏÂÖ®ºó£¬Í¨¹ýphpMyAdmin½øÐзÃÎÊ£¬OKÕý³££¡
±¾´ÎÊý¾ÝÐÞ¸´²Ù×÷³É¹¦£¬Êý¾ÝÒѱ»Õý³£»Ö¸´£¬×ܼÆ85215Ìõ¼Ç¼£¬ÆäÖлָ´Êý¾Ý¹²¼Æ85207Ìõ¡£
×ܽ᱾´Î¾Ñé¼°²éÕÒ×ÊÁÏ£¬ÈçÏ£º
µ±ÄãÊÔͼÐÞ¸´Ò»¸ö±»ÆÆ»µµÄ±íµÄÎÊÌâʱ£¬ÓÐÈýÖÖÐÞ¸´ÀàÐÍ¡£Èç¹ûÄãµÃµ½Ò»¸ö´íÎóÐÅÏ¢Ö¸³öÒ»¸öÁÙʱÎļþ²»Äܽ¨Á¢£¬É¾³ýÐÅÏ¢ËùÖ¸³öµÄÎļþ²¢ÔÙÊÔÒ»´Î--Õâͨ³£ÊÇÉÏÒ»´ÎÐÞ¸´²Ù×÷ÒÅÁôÏÂÀ´µÄ¡£
ÕâÈýÖÖÐÞ¸´·½·¨ÈçÏÂËùʾ£º
% myisamchk --recover --quick /path/to/tblName
% myisamchk --recover /path/to/tblName
% myisamchk --safe-recover /path/to/tblName
µÚÒ»ÖÖÊÇ×î¿ìµÄ£¬ÓÃÀ´ÐÞ¸´×îÆÕͨµÄÎÊÌ⣻¶ø×îºóÒ»ÖÖÊÇ×îÂýµÄ£¬ÓÃÀ´ÐÞ¸´Ò»Ð©ÆäËü·½·¨Ëù²»ÄÜÐÞ¸´µÄÎÊÌâ¡£
¼ì²éºÍÐÞ¸´MySQLÊý¾ÝÎļþ
Èç¹ûÉÏÃæµÄ·½·¨ÎÞ·¨ÐÞ¸´Ò»¸ö±»Ëð»µµÄ±í£¬ÔÚÄã·ÅÆú֮ǰ£¬Ä㻹¿ÉÒÔÊÔÊÔÏÂÃæÕâÁ½¸ö¼¼ÇÉ£º
Èç¹ûÄ㻳ÒɱíµÄË÷ÒýÎļþ(*.MYI)·¢ÉúÁ˲»¿ÉÐÞ¸´µÄ´íÎó£¬ÉõÖÁÊǶªÊ§ÁËÕâ¸öÎļþ£¬Äã¿ÉÒÔʹÓÃÊý¾ÝÎļþ(*.MYD)ºÍÊý¾Ý¸ñʽÎļþ(*.frm)ÖØÐÂÉú³ÉËü¡£Ê×ÏÈÖÆ×÷Ò»¸öÊý¾ÝÎļþ(tblName.MYD)µÄ¿½±´¡£ÖØÆôÄãµÄMySQL·þÎñ²¢Á¬½Óµ½Õâ¸ö·þÎñÉÏ£¬Ê¹ÓÃÏÂÃæµÄÃüÁîɾ³ý±íµÄÄÚÈÝ£º
mysql> DELETE FROM tblName;
ÔÚɾ³ý±íµÄÄÚÈݵÄͬʱ£¬»á½¨Á¢Ò»¸öеÄË÷ÒýÎļþ¡£Í˳öµÇ¼²¢ÖØйرշþÎñ£¬È»ºóÓÃÄã¸Õ²Å±£´æµÄÊý¾ÝÎļþ(tblName.MYD)¸²¸ÇеÄ(¿Õ)Êý¾ÝÎļþ¡£×îºó£¬Ê¹ÓÃmyisamchkÖ´Ðбê×¼µÄÐÞ¸´(ÉÏÃæµÄµÚ¶þÖÖ·½·¨)£¬¸ù¾Ý±íµÄÊý¾ÝµÄÄÚÈݺͱíµÄ¸ñʽÎļþÖØÐÂÉú³ÉË÷ÒýÊý¾Ý¡£
Èç¹ûÄãµÄ±íµÄ¸ñʽÎļþ(tblName.frm)¶ªÊ§ÁË»òÕßÊÇ·¢ÉúÁ˲»¿ÉÐÞ¸´µÄ´íÎ󣬵«ÊÇÄãÇå³þÈçºÎʹÓÃÏàÓ¦µÄCREATE TABLEÓï¾äÀ´ÖØÐÂÉú³ÉÕâÕÅ±í£¬Äã¿ÉÒÔÖØÐÂÉú³ÉÒ»¸öеÄ.frmÎļþ²¢ºÍÄãµÄÊý¾ÝÎļþºÍË÷ÒýÎļþ(Èç¹ûË÷ÒýÎļþÓÐÎÊÌ⣬ʹÓÃÉÏÃæµÄ·½·¨Öؽ¨Ò»¸öеÄ)Ò»ÆðʹÓá£Ê×ÏÈÖÆ×÷Ò»¸öÊý¾ÝºÍË÷ÒýÎļþµÄ¿½±´£¬È»ºóɾ³ýÔÀ´µÄÎļþ(ɾ³ýÊý¾ÝĿ¼ÏÂÓйØÕâ¸ö±íµÄËùÓмǼ)¡£
Æô¶¯MySQL·þÎñ²¢Ê¹Óõ±³õµÄCREATE TABLEÎļþ½¨Á¢Ò»¸öÐÂµÄ±í¡£ÐµÄ.frmÎļþÓ¦¸Ã¿ÉÒÔÕý³£¹¤×÷ÁË£¬µ«ÊÇ×îºÃÄ㻹ÊÇÖ´ÐÐһϱê×¼µÄÐÞ¸´(ÉÏÃæµÄµÚ¶þÖÖ·½·¨)¡£
Èç¹ûÓÐÀàËÆÎÊÌ⣬½¨Òé×Ô¼ºÏÈ·ÖÎöÎÊÌâ¸ùÔ´£¬²éÕÒ×ÊÁÏ£¬×Ô¼º¶¯ÊÖ½â¾ö£¬²»µ«¿ÉÒÔ¶àѧ¸ü¶à֪ʶ¼¼ÇÉ£¬¸üÖØÒªµÄÊÇ£¬×Ô¼ºÒ²ÔÚ½â¾öÎÊÌâµÄͬʱµÃµ½ÁË¿ìÀÖ.