My SQL数据库下损坏数据的恢复操作过程总结
2008-09-03 11:07:12 来源:WEB开发网注:此为记录我当时操作的全部过程
D:Documents and SettingsAdministrator>c:
C:>cd mysql
C:mysql>cd data
C:mysqldata>cd hw_enterprice
C:mysqldatahw_enterprice>myisamchk function_products.frm
‘myisamchk’ 不是内部或外部命令,也不是可运行的程序或批处理文件。
C:mysqldatahw_enterprice>cd
C:>cd mysql
C:mysql>cd bin
注:查看myisamchk的帮助信息
C:mysqlbin>myisamchkmyisamchkVer2.6forWin95/Win98ati32ByMonty,foryourprofessionaluseThissoftwarecomeswithNOWARRANTY:seethePUBLICfordetails.Description,checkandrepairofISAMtables.UsedwithoutoptionsalltablesonthecommandwillbecheckedforerrorsUsage:myisamchk[OPTIONS]tables[.MYI]Globaloptions:-#,–debug=…Outputdebuglog.Oftenthisis‘d:t:o,filename’-?,–helpDisplaythishelpandexit.-O,–set-variablevar=optionChangethevalueofavariable.Pleasenotethatthisoptionisdeprecated;youcansetvariablesdirectlywith‘–variable-name=value’.-t,–tmpdir=pathPathfortemporaryfiles-s,–silentOnlyprinterrors.Onecanusetwo-stomakemyisamchkverysilent-v,–verbosePrintmoreinformation.Thiscanbeusedwith–descriptionand–check.Usemany-vformoreverbosity!-V,–versionPrintversionandexit.-w,–waitWaitiftableislocked.Checkoptions(checkisthedefaultactionformyisamchk):-c,–checkChecktableforerrors-e,–extend-checkCheckthetableVERYthroughly.Onlyusethisinextremecasesasmyisamchkshouldnormallybeabletofindoutifthetableisokevenwithoutthisswitch-F,–fastCheckonlytablesthathaven’tbeenclosedproperly-C,–check-only-changedCheckonlytablesthathavechangedsincelastcheck-f,–forceRestartwith‘-r’ifthereareanyerrorsinthetable.Stateswillbeupdatedaswith‘–update-state’-i,–informationPrintstatisticsinformationabouttablethatischecked-m,–medium-checkFasterthanextend-check,butonlyfinds99.99%ofallerrors.Shouldbegoodenoughformostcases-U–update-stateMarktablesascrashedifyoufindanyerrors-T,–read-onlyDon’tmarktableascheckedRepairoptions(Whenusing‘-r’or‘-o’)-B,–backupMakeabackupofthe.MYDfileas‘filename-time.BAK’–correct-checksumCorrectchecksuminformationfortable.-D,–data-file-length=#Maxlengthofdatafile(whenrecreatingdatafilewhenit’sfull)-e,–extend-checkTrytorecovereverypossiblerowfromthedatafileNormallythiswillalsofindalotofgarbagerows;Don’tusethisoptionifyouarenottotallydesperate.-f,–forceOverwriteoldtemporaryfiles.-k,–keys-used=#TellMyISAMtoupdateonlysomespecifickeys.#isabitmaskofwhichkeystouse.Thiscanbeusedtogetfasterinserts!-r,–recoverCanfixalmostanythingexceptuniquekeysthataren’tunique.-n,–sort-recoverForcesrecoveringwithsortingevenifthetemporaryfilewouldbeverybig.-p,–parallel-recoverUsesthesametechniqueas‘-r’and‘-n’,butcreatesallthekeysinparallel,indifferentthreads.THISISALPHACODE.USEATYOUROWNRISK!-o,–safe-recoverUsesoldrecoverymethod;Slowerthan‘-r’butcanhandleacoupleofcaseswhere‘-r’reportsthatitcan’tfixthedatafile.–character-sets-dir=…Directorywherecharactersetsare–set-character-set=nameChangethecharactersetusedbytheindex-q,–quickFasterrepairbynotmodifyingthedatafile.Onecangiveasecond‘-q’toforcemyisamchktomodifytheoriginaldatafileincaseofduplicatekeys-u,–unpackUnpackfilepackedwithmyisampack.Otheractions:-a,–analyzeAnalyzedistributionofkeys.WillmakesomejoinsinMySQLfaster.Youcancheckthecalculateddistributionbyusing‘–description–verbosetable_name’.-d,–descriptionPrintssomeinformationabouttable.-A,–set-auto-increment[=value]Forceauto_incrementtostartatthisorhighervalueIfnovalueisgiven,thensetsthenextauto_incrementvaluetothehighestusedvaluefortheautokey+1.-S,–sort-indexSortindexblocks.Thisspeedsup‘read-next’inapplications-R,–sort-records=#Sortrecordsaccordingtoanindex.ThismakesyourdatamuchmorelocalizedandmayspeedupthingsC:mysqlbin>myisamchkc:mysqldatahw_enterpricefunction_products.frmmyisamchk:error:‘c:mysqldatahw_enterpricefunction_products.frm’isnotaMyISAM-tableC:mysqlbin>myisamchkc:mysqldatahw_enterpricefunction_products.myiCheckingMyISAMfile:c:mysqldatahw_enterpricefunction_products.myiDatarecords:85207deletedblocks:39myisamchk:warning:Tableismarkedascrashedmyisamchk:warning:1clientsisusingorhasn’tclosedthetableproperly-checkfile-size-checkkeydelete-chain-checkrecorddelete-chainmyisamchk:error:recorddelete-link-chaincorrupted-checkindexreference-checkdatarecordreferencesindex:1-checkdatarecordreferencesindex:2-checkdatarecordreferencesindex:3-checkrecordlinksmyisamchk:error:Wrongbytesec:0-195-171atlinkstart:841908MyISAM-table‘c:mysqldatahw_enterpricefunction_products.myi’iscorruptedFixitusingswitch“-r”or“-o”继续进行操作:C:mysqlbin>myisamchk–recover–quickc:mysqldatahw_enterpricefunction_products.myi-checkkeydelete-chain-checkrecorddelete-chainmyisamchk:error:recorddelete-link-chaincorruptedmyisamchk:error:Quick-recoveraborted;Runrecoverywithoutswitch‘q’UpdatingMyISAMfile:c:mysqldatahw_enterpricefunction_products.myiMyISAM-table‘c:mysqldatahw_enterpricefunction_products.myi’isnotfixedbecauseoferrorsTryfixingitbyusingthe–safe-recover(-o)orthe–force(-f)option系统提示我使用–safe-recover(-o)orthe–force(-f)option进行修复操作,于是C:mysqlbin>myisamchk–safe-recoverc:mysqldatahw_enterpricefunction_products.myi-recovering(withkeycache)MyISAM-table‘c:mysqldatahw_enterpricefunction_products.myi’Datarecords:85207Wrongbytesec:0-195-171at841908;SkippedDatarecords:85215
将修复后的物理文件复制到mysqldata下之后,通过phpMyAdmin进行访问,OK正常!
- ››sql server自动生成批量执行SQL脚本的批处理
- ››Mysql高性能备份方案解决数据不间断访问
- ››sql server 2008亿万数据性能优化
- ››SQL Server 2008清空数据库日志方法
- ››mysql 定时更新表字段列的值状态(存储过程+定时任...
- ››sqlserver安装和简单的使用
- ››SQL Sever 2008 R2 数据库管理
- ››SQL SERVER无法安装成功,sqlstp.log文件提示[未发...
- ››MySQL 生成随机密码
- ››Sql Server中通过父记录查找出所有关联的子记录
- ››mysql创建新用户的命令
- ››MySql Blob图片类型存储Bug解决:索引超出了数组界...
更多精彩
赞助商链接