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

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

Thông tin tài liệu

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

www.it-ebooks.info www.it-ebooks.info LearningMySQLandMariaDB RussellJ.T Dyer Beijing•Cambridge•Farnham•Kưln•Sebastopol•Tokyo www.it-ebooks.info ToFortunataSerio,mymother,whogavemelife,taughtmetobekindandloving,andto speak—whichisaprecursortobeingawriter AndtoAndrewGambos,whohadthethanklessjobofbeingmystepfather,buttaughtme howtoassertmyselfinlifeandinmycareer www.it-ebooks.info www.it-ebooks.info SpecialUpgradeOffer Ifyoupurchasedthisebookdirectlyfromoreilly.com,youhavethefollowingbenefits: DRM-freeebooks—useyourebooksacrossdeviceswithoutrestrictionsorlimitations Multipleformats—useonyourlaptop,tablet,orphone Lifetimeaccess,withfreeupdates Dropboxsyncing—yourfiles,anywhere Ifyoupurchasedthisebookfromanotherretailer,youcanupgradeyourebooktotake advantageofallthesebenefitsforjust$4.99 Clickheretoaccessyourebookupgrade Pleasenotethatupgradeoffersarenotavailablefromsamplecontent www.it-ebooks.info www.it-ebooks.info Foreword BeforeyoubegintoreadthemainchaptersofthisbooktolearnaboutMySQLand MariaDB,itmightbeusefultounderstandwhatweweretryingtoaccomplishwhenwe firstcreatedMySQLabout20yearsagoandMariaDBabout5yearsago,aswellasthe currentstateofthesedatabasesystemsandmyexpectationsofthemgoingforward And I’dliketoencourageyouinyourdecisiontolearnthesedatabasesystemsandtoassure youthattheywillbeinuseforalongtimeandthatyouwillbenefitfromthetimeand energyyouputintoreadingthisbookandlearningwhatithastoteachyou www.it-ebooks.info 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 www.it-ebooks.info toreplaceMySQLasthedominantopensourcedatabase,itwouldhavetobenotonly criticallybetter,butalsoofferawayforpeopletomigratewithoutmucheffort,and withoutwastingalloftheknowledgetheyaccumulatedfromtheircurrentsystem Thisis whyMariaDBcanreplaceMySQL:it’sbasicallythesamething,butwithmorefeatures andmorepotentialforthefuture www.it-ebooks.info www.it-ebooks.info SpecialUpgradeOffer IfyoupurchasedthisebookfromaretailerotherthanO’Reilly,youcanupgradeitfor $4.99atoreilly.combyclickinghere www.it-ebooks.info www.it-ebooks.info 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 www.it-ebooks.info LearningMySQLandMariaDB TableofContents Dedication SpecialUpgradeOffer Foreword OriginsofMySQL StateofMySQLandMariaDB BeyondtheServer MariaDB:TheDifferencesandExpectations TheFutureofMySQLandMariaDB YourFutureinLearningMySQLandMariaDB AdviceonLearningMySQLandMariaDB Preface ReadingStrategy Text-BasedInterfaceandOperatingSystems ConventionsUsedinThisBook UsingCodeExamples Safari®BooksOnline HowtoContactUs Acknowledgments www.it-ebooks.info 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 www.it-ebooks.info 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 www.it-ebooks.info 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 www.it-ebooks.info 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 www.it-ebooks.info 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 www.it-ebooks.info 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 www.it-ebooks.info 14 BackingUpandRestoringDatabases MakingBackups BackingUpAllDatabases UnderstandingDumpFiles BackingUpSpecificDatabases CreatingBackupScripts BackingUpSpecificTables RestoringBackups RestoringaDatabase RestoringaTable Modifyingadumpfile Restoringwithatemporarydatabase Usingalimiteduseraccount RestoringOnlyRowsorColumns RecoveringfromaBinaryLog Findinginformationinthebinarylog Extractingandexecutinginformationfromthebinarylog DevelopingaBackupPolicy Summary Exercises www.it-ebooks.info 15 BulkImportingData PreparingtoImport LoadingDataBasics WatchingforWarnings CheckingtheAccuracyoftheImport SelectingImportedData BetterLoading MappingFields SettingColumns MoreFieldandLineDefinitions Starting,Terminating,andEscaping ReplacingDataVersusIgnoringErrors ImportingfromOutsideMySQL ImportingLocalFiles Usingmysqlimport ImportingWithoutFILEPrivileges BulkExportingData Summary Exercises www.it-ebooks.info 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 www.it-ebooks.info Index AbouttheAuthor Colophon SpecialUpgradeOffer Copyright www.it-ebooks.info ... 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... Anotherkeyprogram,usedextensivelythroughthisbook,is the basic MySQL client, calledsimply, mysql With it, youcaninteract with the mysqlddaemon, and thereby the databases It satextualuserinterface There’snothingfancyabout it —amouseisnot
- 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 , IT training learning MySQL and MariaDB heading in the right direction with MySQL and MariaDB dyer 2015 04 19 , III. Basics of Handling Data

Mục lục

Xem thêm

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