mysql备份和恢复MySQLbackupandrecovery.docx

上传人:b****3 文档编号:3142247 上传时间:2022-11-18 格式:DOCX 页数:6 大小:20.46KB
下载 相关 举报
mysql备份和恢复MySQLbackupandrecovery.docx_第1页
第1页 / 共6页
mysql备份和恢复MySQLbackupandrecovery.docx_第2页
第2页 / 共6页
mysql备份和恢复MySQLbackupandrecovery.docx_第3页
第3页 / 共6页
mysql备份和恢复MySQLbackupandrecovery.docx_第4页
第4页 / 共6页
mysql备份和恢复MySQLbackupandrecovery.docx_第5页
第5页 / 共6页
点击查看更多>>
下载资源
资源描述

mysql备份和恢复MySQLbackupandrecovery.docx

《mysql备份和恢复MySQLbackupandrecovery.docx》由会员分享,可在线阅读,更多相关《mysql备份和恢复MySQLbackupandrecovery.docx(6页珍藏版)》请在冰豆网上搜索。

mysql备份和恢复MySQLbackupandrecovery.docx

mysql备份和恢复MySQLbackupandrecovery

mysql备份和恢复(MySQLbackupandrecovery)

mysql备份和恢复(MySQLbackupandrecovery)

MySQLbackupandrecovery

ThisarticlediscussesthebackupandrecoverymechanismsforMySQLandhowtomaintaindatatables,includingthetwomaintabletypes:

MyISAMandInnodb,andtheMySQLversionofthearticledesignedfor5.0.22.FreebackuptoolscurrentlysupportedbyMySQL:

mysqldump,mysqlhotcopy,alsocanmakeabackupusingSQLsyntax:

BACKUPTABLEorSELECTINTOOUTFILE,orbinarylogbackup(binlog),canalsobedirectlycopythedatafilesandrelatedconfigurationfiles.TheMyISAMtableissavedinafileform,soit'srelativelyeasytobackup,andseveralofthemethodsmentionedabovecanbeused.Innodballthetablesarestoredinthesamedataintheibdata1file(possiblymultiplefiles,orfiletablespaceindependent),relativelygoodsolutionscanbefreebackup,copyadatafile,backupbinlog,ormysqldump.

1,mysqldump

1.1backup

MysqldumpusestheSQLlevelbackupmechanism,whichleadsthedatatableintoSQLscriptfile,whichisrelativelysuitableforupgradingbetweendifferentversionsofMySQL,andthisisthemostcommonlyusedbackupmethod.Nowlet'stalkaboutsomeofthemainparametersofmysqldump:

--compatible=name,ittellsmysqldumpthattheexporteddatawillbecompatiblewitheitherthedatabaseortheolderversionoftheMySQLserver.

ValuescanbeANSI,mysql323,mysql40,PostgreSQL,Oracle,MSSQL,DB2,maxdb,no_key_options,no_tables_options,no_field_options,etc.severalvaluesshouldbeusedandseparatedbycommas.Ofcourse,itisnotguaranteedtobefullycompatible,butcompatibleasmuchaspossible.

Thedataexportedby--complete-insertand-cusesafullINSERTthatcontainsfieldnames,thatis,writeallvaluesinoneline.Doingsoimprovestheinsertionefficiency,butmaybeaffectedbythemax_allowed_packetparametercausingtheinsertiontofail.Therefore,youneedtobecarefulwiththisparameter,atleastIdon'trecommendit.

--default-character-set=charsetspecifiestheexportdatawithwhatcharacterset,ifthedatatableisnotthedefaultLatin1characterset,thenexportthisoptionmustbespecified,otherwiseagainimportdatawillproducegarbled.

--disable-keystoldmysqldumpatthebeginningandendoftheINSERTstatementadded40000ALTERTABLEtableDISABLE/*!

*//*KEYS;and40000ALTERTABLEtableENABLEKEYS!

*/;thisstatementcangreatlyimprovethespeedoftheinsertstatement,becauseitisintheinsertallthedataafterthe

reconstructionoftheindex.ThisoptionisonlysuitableforMyISAMtables.

--extended-insert=true|false,bydefault,mysqldumpopens--complete-insertmode,soifyoudon'twanttouseit,usethisoptionandsetittofalse.

--hex-blobexportsbinarystringfieldsusingthesixteendecimalformat.Ifyouhavebinarydata,youmustusethisoption.ThefieldtypesthataffectareBINARY,VARBINARY,andBLOB.

--lock-all-tables,-x,beforeyoustartexporting,submitrequeststolockalltablesinalldatabasestoensuredataconsistency.Thisisaglobalreadlock,andautomaticallyclosesthe--single-transactionand--lock-tablesoptions.

--lock-tablesissimilarto--lock-all-tables,butlocksthecurrentlyexporteddatatableinsteadoflockingallthetablesunderthelibraryatonce.ThisoptionappliesonlytotheMyISAMtable,andifitisanInnodbtable,youcanusethe--single-transactionoption.

--no-create-info,-tonlyexportsdatawithoutaddingtheCREATETABLEstatement.

--no-data,-ddoesnotexportanydata,onlyexportthedatabasetablestructure.

--opt,thisisjustashortcutoption,equivalenttoaddingthe--add-drop-tables--add-locking--create-option

--disable-keys--extended-insert--lock-tables--quick--set-charsetoptionatthesametime.Thisoptionallowsmysqldumptoexportdataquickly,andtheexporteddatacanbequicklyreturned.Thisoptionisturnedonbydefault,butcanbedisabledby--skip-opt.Notethatifyourunmysqldumpwithoutspecifyingthe--quickor--optoption,youwillputtheentireresultsetinmemory.Problemscanariseifyou

exportlargedatabases.

--quick,

-qthisoptionisusefulwhenexportinglargetables,whichforcemysqldumptoretrieverecordsdirectlyfromtheserverquery,andcachethemdirectlyintomemorywithoutobtainingallrecords.

--routines,-Rexportstoredprocedures,andcustomfunctions.

--single-transactionthisoptionprovidesaBEGINSQLstatementbeforeexportingdata,andBEGINdoesnotblockanyapplicationandguaranteestheconsistencyofthedatabasewhenexporting.Itappliesonlytotransactiontables,suchasInnoDBandBDB.Thisoptionandthe--lock-tablesoptionaremutuallyexclusivebecauseLOCKTABLEScausesanypendingtransactionstobeimplicitlycommitted.Ifyouwanttoexportlargetables,youshouldcomb

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1