IT training learning MySQL and MariaDB heading in the right direction with MySQL and MariaDB dyer 2015 04 19 1

443 21 0
  • Loading ...
1/443 trang
Tải xuống

Thông tin tài liệu

Ngày đăng: 05/11/2019, 15:07

LearningMySQLandMariaDB RussellJ.T Dyer Beijing•Cambridge•Farnham•Kưln•Sebastopol•Tokyo ToFortunataSerio,mymother,whogavemelife,taughtmetobekindandloving,andto speak—whichisaprecursortobeingawriter AndtoAndrewGambos,whohadthethanklessjobofbeingmystepfather,buttaughtme howtoassertmyselfinlifeandinmycareer SpecialUpgradeOffer Ifyoupurchasedthisebookdirectlyfromoreilly.com,youhavethefollowingbenefits: DRM-freeebooks—useyourebooksacrossdeviceswithoutrestrictionsorlimitations Multipleformats—useonyourlaptop,tablet,orphone Lifetimeaccess,withfreeupdates Dropboxsyncing—yourfiles,anywhere Ifyoupurchasedthisebookfromanotherretailer,youcanupgradeyourebooktotake advantageofallthesebenefitsforjust$4.99 Clickheretoaccessyourebookupgrade Pleasenotethatupgradeoffersarenotavailablefromsamplecontent Foreword BeforeyoubegintoreadthemainchaptersofthisbooktolearnaboutMySQLand MariaDB,itmightbeusefultounderstandwhatweweretryingtoaccomplishwhenwe firstcreatedMySQLabout20yearsagoandMariaDBabout5yearsago,aswellasthe currentstateofthesedatabasesystemsandmyexpectationsofthemgoingforward And I’dliketoencourageyouinyourdecisiontolearnthesedatabasesystemsandtoassure youthattheywillbeinuseforalongtimeandthatyouwillbenefitfromthetimeand energyyouputintoreadingthisbookandlearningwhatithastoteachyou OriginsofMySQL WhenmybusinesspartnerDavidAxmarkandIstartedMySQL,thereweren’tanygood, free,opensourcedatabasesystems TherewasmSQL,whichwasn’topensource,butit inspiredustocreateanewdatabasesystemforourclients,whichwouldlaterbecome MySQL WehadnoplanstodoanythingmorewiththisembryoofMySQLotherthan satisfytheneedsofourclients Wewerelearning,discovering,andcreatingoutof practicalconcernsandneeds,muchasyoumightandperhapsshouldbedoingasareader ofthisbookandanewcomertoMySQLandMariaDB Althoughwehadaccomplishedourtaskincreatingastraightforwarddatabasetomeetour requirements,itwasn’tlongbeforewenoticedthatthereweremanyotherorganizations thatwerelookingforasolutionsimilartowhatwehadalreadydeveloped Sowedecided tomakethesoftwareavailabletothepublicandwenameditMySQL Partofourmotivationfordoingthiswasthatwefeltthatitwasawayinwhichwecould givesomethingbacktotheopensourcecommunitythatwouldbeveryuseful Mostopen sourceprojectsatthattimeweren’tasuseful Wewantedtomaketheworldalittlebetter —wehadnoideaatthattimehowmuchofanimpactMySQLwouldhaveontheworld Atthesametime,wewerehopingthatbygoingpublicwiththesoftware,itmightfinance furtherdevelopmentofMySQLforaslongaswemightwant Wehadexpectationsof gettingrichfromMySQL Wehopedonlytobeabletoworkfull-timeonthisproject becausewebelievedinit Theresult,though,wasthatwecontributedmuchtotheworld —muchmorethanwethoughtpossible Giventhefactthatover80%ofthewebsitesintheworldarenowrunningonMySQL, onecouldeasilyarguethatweacceleratedthegrowthoftheinternetandalmost everythingthathasgrownoutofit Theimpactit’shadisimmeasurable Manyofthesites andbusinessesthathavebeensuccessful,includingtheonesthatarenowhuge,probably wouldneverhavestartedifitwerenotforMySQLbeingfreeanddependable Atthat time,thosefoundersandstartupcompaniesjustdidn’thavethefinancialresourcestostart theirsites Thecostofcommercialdatabasesoftwarewasabarriertosomeofthemost creativeweb-basedorganizationsbeinglaunched,includingorganizationslikeGoogle, Wikipedia,andFacebook Plus,thecommercialdatabasesystemsposedotherproblems forstartupsofthattime First,theyweretooslow—theyweren’toptimizedfortheWeb andthatwascriticalfororganizationslikethese Thecommecialalternativeswerealsotoo difficulttouseandmanage,requiringhigherpaiddevelopers Becauseofthesefactors,wewereabletogivefledglingorganizationswhattheyneededto becomethesignificantcomponentsoftheInternetandamajorpartofthelivesofmost peopleintheworldtoday Wewereacriticalcomponentofthedevelopmentofthe Internetandwestillare There’snothingtoindicatethatwewon’tcontinuetobeso The growthofMySQLandespeciallyofMariaDBisincreasing It’snotdecreasingassome peopleexpectedwiththeintroductionofnewdatabasessystemsandmethodssuchas NoSQL MySQLbecameadominantdatabasesystemlongago Oncesomethingbecomes dominant,it’sdifficulttoreplaceit Evenifsomethingbettercomesalong,peopleprefer what’salreadyfamiliartothemandwhattheyalreadyknowandareusing Forsomething toreplaceMySQLasthedominantopensourcedatabase,itwouldhavetobenotonly criticallybetter,butalsoofferawayforpeopletomigratewithoutmucheffort,and withoutwastingalloftheknowledgetheyaccumulatedfromtheircurrentsystem Thisis whyMariaDBcanreplaceMySQL:it’sbasicallythesamething,butwithmorefeatures andmorepotentialforthefuture SpecialUpgradeOffer IfyoupurchasedthisebookfromaretailerotherthanO’Reilly,youcanupgradeitfor $4.99atoreilly.combyclickinghere LearningMySQLandMariaDB RussellJ.T Dyer Editor AndyOram RevisionHistory 2015-03-23 Firstrelease Copyright©2015RussellDyer O’Reillybooksmaybepurchasedforeducational,business,orsalespromotionaluse Onlineeditionsarealsoavailable formosttitles(http://safaribooksonline.com) Formoreinformation,contactourcorporate/institutionalsalesdepartment: 800-998-9938orcorporate@oreilly.com TheO’ReillylogoisaregisteredtrademarkofO’ReillyMedia,Inc LearningMySQLandMariaDB,theimageofa bandedangelfish,andrelatedtradedressaretrademarksofO’ReillyMedia,Inc Manyofthedesignationsusedbymanufacturersandsellerstodistinguishtheirproductsareclaimedastrademarks Wherethosedesignationsappearinthisbook,andO’ReillyMedia,Inc wasawareofatrademarkclaim,the designationshavebeenprintedincapsorinitialcaps Whilethepublisherandtheauthorhaveusedgoodfaitheffortstoensurethattheinformationandinstructionscontained inthisworkareaccurate,thepublisherandtheauthordisclaimallresponsibilityforerrorsoromissions,including withoutlimitationresponsibilityfordamagesresultingfromtheuseoforrelianceonthiswork Useoftheinformation andinstructionscontainedinthisworkisatyourownrisk Ifanycodesamplesorothertechnologythisworkcontainsor describesissubjecttoopensourcelicensesortheintellectualpropertyrightsofothers,itisyourresponsibilitytoensure thatyourusethereofcomplieswithsuchlicensesand/orrights O’ReillyMedia 1005GravensteinHighwayNorth Sebastopol,CA95472 2015-03-28T14:05:40-07:00 LearningMySQLandMariaDB TableofContents Dedication SpecialUpgradeOffer Foreword OriginsofMySQL StateofMySQLandMariaDB BeyondtheServer MariaDB:TheDifferencesandExpectations TheFutureofMySQLandMariaDB YourFutureinLearningMySQLandMariaDB AdviceonLearningMySQLandMariaDB Preface ReadingStrategy Text-BasedInterfaceandOperatingSystems ConventionsUsedinThisBook UsingCodeExamples Safari®BooksOnline HowtoContactUs Acknowledgments I TheSoftware Introduction TheValueofMySQLandMariaDB MailingListsandForums OtherBooksandOtherPublications InstallingMySQLandMariaDB TheInstallationPackages Licensing FindingtheSoftware ChoosingaDistribution The_AMPAlternatives LinuxBinaryDistributions MacOSXDistributions WindowsDistributions FreeBSDandSunSolarisDistributions SourceDistributions Post-Installation SpecialConfiguration SettingInitialPasswordforroot MoreonPasswordsandRemovingAnonymousUsers CreatingaUser TheBasicsandthemysqlClient ThemysqlClient ConnectingtotheServer StartingtoExploreDatabases FirstSQLCommands InsertingandManipulatingData ALittleComplexity Summary Exercises II DatabaseStructures CreatingDatabasesandTables CreatingaDatabase CreatingTables InsertingData MorePerspectivesonTables Summary Exercises AlteringTables PrudenceWhenAlteringTables EssentialChanges DynamicColumns OptionalChanges SettingaColumn’sDefaultValue SettingtheValueofAUTO_INCREMENT AnotherMethodtoAlterandCreateaTable RenamingaTable ReorderingaTable Indexes Summary Exercises III BasicsofHandlingData InsertingData TheSyntax PracticalExamples TheTableforBirdOrders TheTableforBirdFamilies TheTableforBirds OtherPossibilities InsertingEmphatically InsertingDatafromAnotherTable ADigression:SettingtheRightID ReplacingData PrioritiesWhenInsertingData Loweringthepriorityofaninsert DelayinganINSERT RaisingthepriorityofanINSERT Summary Exercises SelectingData BasicSelection SelectingbyaCriteria OrderingResults LimitingResults CombiningTables ExpressionsandtheLike CountingandGroupingResults Summary Exercises UpdatingandDeletingData UpdatingData UpdatingSpecificRows LimitingUpdates OrderingtoMakeaDifference UpdatingMultipleTables HandlingDuplicates DeletingData DeletinginMultipleTables Summary Exercises JoiningandSubqueryingData UnifyingResults JoiningTables SelectingaBasicJoin UpdatingJoinedTables DeletingWithinJoinedTables Subqueries ScalarSubqueries ColumnSubqueries RowSubqueries TableSubqueries PerformanceConsiderationswithSubqueries Summary Exercises IV Built-InFunctions 10 StringFunctions FormattingStrings ConcatenatingStrings SettingCaseandQuotes TrimmingandPaddingStrings ExtractingText SearchingStringsandUsingLengths LocatingTextWithinaString StringLengths ComparingandSearchingStrings ReplacingandInsertingintoStrings ConvertingStringTypes CompressingStrings Summary Exercises 11 DateandTimeFunctions DateandTimeDataTypes CurrentDateandTime ExtractingDateandTimeComponents FormattingDatesandTime AdjustingtoStandardsandTimeZones AddingandSubtractingDatesandTime ComparingDatesandTimes Summary Exercises 12 AggregateandNumericFunctions AggregateFunctions CountingValues CalculatingaGroupofValues ConcatenatingaGroup NumericFunctions RoundingNumbers RoundingOnlyDownorUp TruncatingNumbers EliminatingNegativeNumbers Summary Exercises V AdministrationandBeyond 13 UserAccountsandPrivileges UserAccountBasics RestrictingtheAccessofUserAccounts UsernameandHost SQLPrivileges DatabaseComponentsandPrivileges Restrictingtospecificdatabases Restrictingtospecifictables Restrictingtospecificcolumns AdministrativeUserAccounts UserAccountforMakingBackups UserAccountforRestoringBackups UserAccountforBulkImporting UserAccounttoGrantPrivileges RevokingPrivileges DeletingaUserAccount ChangingPasswordsandNames SettingaUserAccountPassword RenamingaUserAccount UserRoles Summary Exercises 14 BackingUpandRestoringDatabases MakingBackups BackingUpAllDatabases UnderstandingDumpFiles BackingUpSpecificDatabases CreatingBackupScripts BackingUpSpecificTables RestoringBackups RestoringaDatabase RestoringaTable Modifyingadumpfile Restoringwithatemporarydatabase Usingalimiteduseraccount RestoringOnlyRowsorColumns RecoveringfromaBinaryLog Findinginformationinthebinarylog Extractingandexecutinginformationfromthebinarylog DevelopingaBackupPolicy Summary Exercises 15 BulkImportingData PreparingtoImport LoadingDataBasics WatchingforWarnings CheckingtheAccuracyoftheImport SelectingImportedData BetterLoading MappingFields SettingColumns MoreFieldandLineDefinitions Starting,Terminating,andEscaping ReplacingDataVersusIgnoringErrors ImportingfromOutsideMySQL ImportingLocalFiles Usingmysqlimport ImportingWithoutFILEPrivileges BulkExportingData Summary Exercises 16 ApplicationProgrammingInterfaces CreatingAPIUserAccounts CAPI ConnectingtoMySQL QueryingMySQL CompleteMinimalCAPIProgram CompilingwithCIncludes PerlDBI Installing ConnectingtoMySQL QueryingMySQL Selectingdata Updatingdata AFullExamplewithPerlDBI MoreInformation PHPAPI InstallingandConfiguring ConnectingtoMySQL QueryingMySQL MoreInformation Python Installing ConnectingtoMySQL QueryingMySQL SamplePythonProgram MoreInformation RubyAPI InstallingandPreparingMySQL/Ruby ConnectingtoMySQL QueryingMySQL SampleMySQL/RubyProgram MoreInformation SQLInjection Summary Exercises Index AbouttheAuthor Colophon SpecialUpgradeOffer Copyright ... operatingsystemsdistributors,hardwaremakers, and softwarepackagersarenow shippingtheirproducts with MariaDB, eithertogether with MySQL orwithout it Many websitesthatused MySQL softwarehaveswitchedto MariaDB It seasytodo, and for... VicePresidentofServicesat MySQL, Inc.,along with otherformeremployeesof MySQL, leftSun and Oracle and startedSkySQLAb,providingsupport,consulting, training, and otherservicesrelatedto MySQL and MariaDB software... It isthiscollaborativeeffortthatIdon’texpectfromOracleregarding MySQL That’s the difference and advantageof MariaDB With Oracle,there’snocertainty in the futureof the opensourcecodeof MySQL With MariaDB, bydesign it willalwaysbeopensource
- Xem thêm -

Xem thêm: IT training learning MySQL and MariaDB heading in the right direction with MySQL and MariaDB dyer 2015 04 19 1 , IT training learning MySQL and MariaDB heading in the right direction with MySQL and MariaDB dyer 2015 04 19 1 , III. Basics of Handling Data

Mục lục

Xem thêm

Gợi ý tài liệu liên quan cho bạn