Youcanassignthemallprivilegessothattheyhavetheabilitytoinsearchdropupdatewithinyourdatabaseserver, you'regonnasignspecificprivileges, soyoucansimplysay I onlywantthisuseraccounttobeabletoselect.
Soimagineifyou'recreating a script, orimagineifyou'regivinguseraccesstoyourdatabaseandyou'resaying, Hey, I wantyoutobeabletorunreports, but I don't wantyoutobeabletoaddanything.
And I don't wantyouMabelupdateanything.
All I wantyoutodoisbeabletobeabletojustrunthereports, thenthat's howyoucanassignprivilegestoallowpeopletoonlydotheexactthingsthatyouwanttodioOneofcoolthingsinthemiceEqualworldisyoucanreallygetrelativelygranularandthepermissionsthatyouareabletoassigndifferentusers.
Sowehaveinthelabthatwe'vebeendoingwith a Class D B databaseandthenwithinthatClass D B database, wehave a user's tablesowecouldsaythatthisuserhastheabilitytodowhatevertheywantwithinanytableswithintheClass D V database.
That's onethingthatyoucould d'oh!
Youcanassignjust a tablesotheyonlyhaveaccesstooneparticulartable.
Oneofthereasonswehavesomanyissueswithhackersinthecybersecurityworldisfrankly, a lotofourinfrastructureisnotbuiltwiththesecuritythatisalreadybuiltintothesystem.
Again, ifyou'rethinkingaboutdoingsomethinglike a sequelinjectionattackonandyou'reusingsometypeofWebpageinordertotrytohackinto a databaseserver, well, thefactofthematteris, isthisisifyourestrictthepermissionssothattheuseraccountthatthatscriptisattackedtwocanonlydoselectorcanevenonLeedoselecton a oneparticularcolumnononetable?
Thefactofthematteris, theattacksurfacethatisthat a hackermaygoafterjustsimplybecomes a lotsmaller.
Andsowhat?
I'm gonnabeshowingyoutoday's againhowtocreatetheseuseraccounts, howtoassigntheprivilegesandget a littlebitintothingslikerevokingprivilegesandthattypeofthing.
So, as I saidmanytimesbeforewarningorder, willRobinsonorneedwarning s o thethingsthat I'm goingtobeTIFyoudotodayare a verysmallsubsetofthesecuritythatyou'reabletodoin a mysequeldatabaseserver.
Itisamazingliterallyhowmuchsecurityisactuallybuiltintomysequeldatabaseserver, andyoucouldprobablydo a whole 10 hourclassjustgoingoverallthedifferentsecurityfeaturesthatareavailable.
Sowhat I'm goingtobedoingis I'm goingtobeshowingyou a smallsubsetofwhatyouareabletodio.
WehaveDebbieinhaIfinsistsmysequel, ThatSession I sequel, AssistsandRoot, andyoucanseeoverhereforhost.
WeseelocalhostrightonDSOHostisoneofthosethingswewillgetintoMaurin a differentclass.
Thisisimportantwithsecurityforfrom a differentfrom a differentstandpoint, buttheimportantthingtorealizewithuseraccounts, solikewhenyou'realonginitandwhenyou'reusing a useraccountwithinmysequeldatabaseserverbasicallyyourusername, andthehostiscombinedinordertocreateyouruseraccount.
SoifyouhadTimatlocalhost, thatwouldbe a differentuseraccountthansimplyTimwithoutanyhostwhichwillbe a differentuseraccountthanTimat 192.168 not 1.4.
So, basically, whenyou'rewhenyou'reidentifyinguseraccount, theyouhavetheusernameandthehostcometogethertoactuallycreatethatuseraccount.
Sothisisoneofthosethingsagain.
Itgets a littlebitcomplicated.
We'rejustgoingtobedealingwith a localhostforthehosttoday.
So, inordertorevoketheprivilege, allyoudoisyoudorevoke, andthenyoudoinserttheysayonandthenwhateveritis s o Class D, B, uh, users.
Andthenyousay, umfromandthenwhoyou'reyou'regetting a front.
SoBobatlocalitsgoalhost, rightsemicolon.
SorevoketheinsertprivilegeonclassdotTVuserstotheuser's tablewithintheclass D V databasefromBobatlocalhost.
Andthenwehit.
Enterquery.
Okay, zeroseffective, blah, blah.
Andthenwhatwecoulddohereisnow a newshow.
BrandsforBobatlocalhost, semicolonhit, Enter.
Andsonowhehastheselectabilityonalltablesandalldatabases, buthenowonlyhastheupdateabilityontheagecolumnwithintheuser's tableoftheclass D B totheclassdatabase.
Andsothat's how I showedyoutocreate a useraccountthat I showedyouhowtogiveprivilegestothatuseraccount.
Andthenthat's it.
Then I showedyouhowtorevokeprivilegesfromuseraccountagainwhenyouwanttotake a lookatallprivilegesisalltheprivilegesistheprivileges, butthemainonesthatyoushouldbeworriedaboutatthistimeagainiscreatedrop, delete, insert, selectorupdate.
Rightthenthere's a finalonecalledAllPrivileges.
Soifwewanttocreate a useraccountandgivethemallprivileges, sothiswaytheycandowhatevertheywantsotheycanupdate.
I keep I keepgettingstupidonwheretheeyeswherethekeysarebutanywaysranallpro.
Soallprivilegesisbasicallyifyou'reusedtotheWindowsworld, thiswillbefullcontrolGrantbasicallyfullcontrolallprivilegesonAndthenwesay, Whatwhatwewantitonwecando a singledatabasesowecouldsimplydoclass.
Ifyouhave a a superuseraccount, youwanttogivethemallprivilegestostartoutstar.
Butthisisanexampleofwhyyoureallyneedtothinkaboutandsay, Well, no, I wanttogiveallprivilegesThiotwoclass D b A dotstar.
SoalltableswithintheClass D B database.
SosomeofthosethingstothinkaboutSonowyouknowhowtocreate a user, youknow, howdoyougiveprivilegestoeverythingto a singledatabaseto a singletablewithin a databaseyouinto a singlecolumnwithin a tablewithin a database.
Youknow, ratherrefinedprivilegesallthewaydownto a singlecolumnon a singletablein a singledatabaseonsomeofthiscouldbeveryvaluableagain.
Thisisanimportantthingtobethinkingaboutfrom a securitystandpoint, especiallywhenyoustartcreatingscripts.
Basicallystartcreatingthosefrontendstobeofinteractingormysequeldatabaseisrememberagainif a hackertriestousesomethinglikewhat's called a sequel, injection, attackordifferenttypesofattack, iftheuseraccountthatthey'reessentiallytryingtohijacksimplydoesn't havethepermissionstodotheattacksthatthey'retryingto D'oh!
It's gonnafailoutagain.
Likeifyouifyoucreate a frontendandallthatfrontendisgoingtodoisit's goingtoe, youknow, pull a reportfrom a particulartablewithinyourdatabase.
Ifyou'regoingtohave a frontendandallthat's goingtodoisbeabletopull a report, thenbasicallygivethatfrontendbasicallytheuseraccountthatthatfrontendisusing, giveitthepermissiontobeabletodoselectstatementson a specifictablein a specificdatabase.
Andthat's it, evenof a hackerisabletocompromiseyourscriptthatfrontendandbeabletotrytodosomekindofinjectionattacksorsomethingelse.
Sothesearesomethingstobethinkingaboutnow a finalthing a finalthingagain.
I wastalkingaboutthesedifferent, uh, thesedifferentusersagain, whereyoucanhaveTimas a userandyoucanhaveTimatlocalhostas a userandTimatsomethingelsetotheuser.
Letmejustgooutofthecomputeragainjusttokindofshowyouhowyoucancreate a bitof a messwiththis.
I don't wanttogettoofardowntherabbitholewiththisisnowyou'resittingtheregoing.
Okay, Well, well, thenififtheycouldonlyloginremotelyortheyOnleyloginfrom a particular I P addressyouknow, howdoesthatworkforsecuritywhenitcomestothingslikescripts?
Soifyouloginwith s s age, youcanuse a localhostuseraccounttologinwithus a safebecause S s a isessentially, eventhoughyou'reremotelyyourremotelyconnectinglocally.
Butifyoudothat, youmightstartrunningintosomeweirdproblemswhenyoutrytodothingslike a logginginItwaskindofinterestingbecause I'vebeenhammeringthehelloutofthislittlemiceequalthatof a serverinordertodothesetheseclasses, right?
So I createuseraccounts.
I deleteuseraccountsandcreateallkindsofandyeah, I found I foundsomeweirdplaces.
I foundsomeweirdplaceswhereifyouscrewaroundwiththeusertabletoomuch, youruseraccountsactuallywon't beabletologintothemysequeldatabaseserver, andyourunintosomeproblemsthatway.
There's someinterestingthings.
Ifyougowhenyoudosomefurtherresearchabouthowmysequelactuallyparse, isthatuserstableforwhenpeopletrytolowagainandhowthatwholepasswordprocessworksand I'llsay, isifyouifyoustartnothingtoomuchintotheuser's table, youstartdoing a lotofmodifications, thattypeofthing.
Youcouldrunintosomereallyquirks.
Andsoifyougettothepointwhereforsomereasontheuseraccountthatyoucreatedisnotabletolonginyourdatabaseserver, what I wouldarguethatthesimplewaytotroubleshootintothisPointsays, thisisallLabisbasicallydeletealltheuseraccountsthatyoucreatedandthenrecreatetheuseraccountsandshouldbeabletofixtheproblem.
Butagain, ifyou'redealingwith a realproductionserver, youmayhavetodosomeGooglesearching.
I justrealizedtheissuethatyoumayrunintoisthereIsthisbasicallyhowmysequelparsesthattableWhenyougotolawagain, youcanrunintosomereallyweird, quirkyproblemsthere.
Ifyouhave a frontendwherepeoplearegoingtobepullingreportsfromyourdatabaseserver, justsimplyaskyourself, whywouldyougivetheuseraccountthatisaccessingyourmysingledatabaseserver?
Downtothecolumnsthinkaboutthatevenwith, like, selectagainspecific, specifictablesspecificonlybeing a pullinformationfromspecificcolumns.
Sowhy, IfyouhaveSocialSecuritynumbers, ifyouhavecreditcardnumbers, whywhywould a frontendbeusing a useraccountthatevenhastheabilitytobeabletoselectandbeabletoreadcreditcardinformation?
We'lltalkaboutthoseremoteaccountsandthosetypesofthings, Butwithwhat I showyourightnow, youshouldbeabletostartandandbeabletoplayaroundwithmysingledatabaseserverandactuallydosomeinterestingthings.
So, asalways, I enjoydoingthisvideoandlookfortoseeonthenextone.
Apparently, thetypeofcontentyoujustsawisnotwhatSusan W.
WantsforthefutureofYouTube.
ThismeansthatrecommendationsbyYouTubetothischannelhavedroppedmassivelyandviewsarebecoming a comicallysmall I hatetoask.
I usedtosay I wouldneverask, butifyoucouldsubscribelikecommonandmostimportantly, sharethevideosthatyouappreciate, thatmayhelpslowthedeathofthischannel.