GentooMySQL Startup GuideWord格式文档下载.docx

上传人:b****5 文档编号:21645518 上传时间:2023-01-31 格式:DOCX 页数:18 大小:24.18KB
下载 相关 举报
GentooMySQL Startup GuideWord格式文档下载.docx_第1页
第1页 / 共18页
GentooMySQL Startup GuideWord格式文档下载.docx_第2页
第2页 / 共18页
GentooMySQL Startup GuideWord格式文档下载.docx_第3页
第3页 / 共18页
GentooMySQL Startup GuideWord格式文档下载.docx_第4页
第4页 / 共18页
GentooMySQL Startup GuideWord格式文档下载.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

GentooMySQL Startup GuideWord格式文档下载.docx

《GentooMySQL Startup GuideWord格式文档下载.docx》由会员分享,可在线阅读,更多相关《GentooMySQL Startup GuideWord格式文档下载.docx(18页珍藏版)》请在冰豆网上搜索。

GentooMySQL Startup GuideWord格式文档下载.docx

#emerge--pretend--verbosemysql

(InstallMySQL)

#emergemysql

Uponcompletionoftheinstallation,youwillseethefollowingnotice:

1.2:

MySQLeinfomessage

Youmightwanttorun:

"

emerge--config=dev-db/mysql-[version]"

ifthisisanewinstall.

Sincethisisanewinstallation,werunthecommand.YouneedtopressENTERwhenpromptedwhileconfiguringtheMySQLdatabase.TheconfigurationsetsupthemainMySQLdatabasewhichcontainsadministrativeinformationsuchasdatabases,tables,users,permissionsandmore.Theconfigurationrecommendsthatyouchangeyourrootpasswordassoonaspossible.Wewilldefinitelydothis,otherwisesomeonecouldcomealongbychanceandhackourdefaultsetupMySQLserver.

1.3:

MySQLconfiguration

(Replace[version]withtheversionnumberyouhavejustinstalled.)

#emerge--config=dev-db/mysql-[version]

*MySQLDATADIRis/var/lib/mysql

*PressENTERtocreatethemysqldatabaseandsetproper

*permissionsonit,orControl-Ctoabortnow...

Preparingdbtable

Preparinghosttable

Preparingusertable

Preparingfunctable

Preparingtables_privtable

Preparingcolumns_privtable

Installingallpreparedtables

Tostartmysqldatboottimeyouhavetocopysupport-files/mysql.server

totherightplaceforyoursystem

PLEASEREMEMBERTOSETAPASSWORDFORTHEMySQLrootUSER!

Todoso,issuethefollowingcommandstostarttheserver

andchangetheapplicablepasswords:

(Notethenext3lines)

/etc/init.d/mysqlstart

/usr/bin/mysqladmin-uroot-hpegasospassword'

new-password'

/usr/bin/mysqladmin-urootpassword'

Dependingonyourconfiguration,a-poptionmaybeneeded

inthelastcommand.Seethemanualformoredetails.

(SomeMySQLnon-ebuildspecificinformationhasbeenremovedfromhere

soastokeepthisdocumentasconsistentaspossible)

*ForsecurityreasonsyoushouldsetyourMySQLroot

*passwordassoonaspossible.

Important:

Asofmysql-4.0.24-r2,passwordsareenteredduringtheconfigphasemakingrootpasswordentrymoresecure.

Theconfigscripthasalreadyprintedoutthecommandsweneedtoruntosetupourpassword,soweshallnowrunthem.

1.4:

SettingupyourMySQLrootpassword

#/etc/init.d/mysqlstart

*Re-cachingdependencyinfo(mtimesdiffer)...

*Startingmysqld(/etc/mysql/f)...[ok]

(Replacenew-passwordwithyourdesiredpassword)

#/usr/bin/mysqladmin-uroot-hlocalhostpassword'

YoucannowtestthatyourrootpasswordwassuccessfullyconfiguredbytryingtologintoyourMySQLserver:

1.5:

LoggingintotheMySQLserverusingmysql

$mysql-uroot-hlocalhost-p

Enterpassword:

WelcometotheMySQLmonitor.Commandsendwith;

or\g.

YourMySQLconnectionidis4toserverversion:

4.0.25

Type'

help;

'

or'

\h'

forhelp.Type'

\c'

toclearthebuffer.

mysql>

The-uswitchsetstheuserthatwillbeloggingin.The-hswitchsetsthehost.Thiswillusuallybelocalhostunlessyouaresettinguparemoteserver.Finally,-ptellsthemysqlclientthatyouwillbeenteringapasswordtoaccessyourdatabase.Noticethemysql>

prompt.Thisiswhereyoutypeinallyourcommands.Nowthatwe'

reinthemysqlpromptastherootuser,wecanbegintosetupourdatabase.

2. 

SettingUpTheDatabase

CreatingADatabase

Wehaveloggedinandamysqlpromptisdisplayed.Firstlet'

stakealookatthedatabaseswecurrentlyhave.Todoso,weusetheSHOWDATABASEScommand.

2.1:

DisplayingMySQLdatabases

SHOWDATABASES;

+----------+

|Database|

|mysql|

|test|

2rowsinset(0.09sec)

PleaserememberthatMySQLcommandsshouldendwithasemicolon--;

Despitethefactthatatestdatabaseisalreadycreated,wearegoingtocreateourown.DatabasesarecreatedusingtheCREATEDATABASEcommand.We'

llcreateonenamed"

gentoo"

.

2.2:

Creatingthegentoodatabase

CREATEDATABASEgentoo;

QueryOK,1rowaffected(0.08sec)

Theresponseletsusknowthatthecommandwasexecutedwithoutanyerrors.Inthiscase,1rowwasmodified.Thisisareferencetothemainmysqldatabase,whichcarriesalistofallthedatabases.Youwon'

tneedtoworrytoomuchaboutthebackgrounddetails.Thelastnumberishowfastthequerywasexecuted.WecanverifythedatabasewascreatedbyrunningtheSHOWDATABASEScommandagain.

2.3:

Verifingthedatabaseiscreated

|gentoo|

3rowsinset(0.00sec)

Indeedourdatabasehasbeencreated.Inordertoworkwithcreatingtablesforournewgentoodatabase,weneedtoselectitasourcurrentdatabase.Todoso,weusetheUSEcommand.TheUSEcommandtakesthenameofthedatabaseyouwishtouseasyourcurrentdatabase.Anotheroptionistosetitonthecommandlineafterthe-Dswitch.Let'

sgoaheadandswitchtothegentoodatabase.

2.4:

Switchingourdatabase

USEgentoo;

Databasechanged

Andthecurrentdatabaseisnowourpreviouslycreatedgentoodatabase.Nowthatwe'

reusingit,wecanstarttocreatesometablesandputinformationinthem.

3. 

WorkingWithTablesInMySQL

CreatingaTable

InthestructureofMySQL,therearedatabases,tables,records,andfields.Databasesholdtogethertables,tablesholdtogetherrecords,recordsholdtogetherfields,whichcontaintheactualinformation.Thisstructureletsusersselecthowtheywanttoaccesstheirinformation.Sofarwe'

vedealtwithdatabases,nowlet'

sworkwithtables.Firstoff,tablescanbelistedsimiliarlytodatabasesusingtheSHOWTABLEScommand.Rightnowtherearenotablesinourgentoodatabase,asrunningthecommandwillshowus:

3.1:

EmptygentooDatabase

SHOWTABLES;

Emptyset(0.00sec)

Thismeansweneedtocreatesometables.Inordertodoso,weusetheCREATETABLEcommand.However,thiscommandisquitedifferentfromsimpleCREATEDATABASEcommand.Thiscommandtakesalistofarguments.Theformisasfollows:

3.2:

CREATETABLESyntax

CREATETABLE[table_name]([field_name][field_data_type]([size]));

table_nameisthenameofthetablewewishtocreate.Inthiscase,let'

smakeatablenameddevelopers.Thistablewillcontainthedeveloper'

sname,emailandjob.field_namewillcontainthenameofthefield.Wehave3requirednamesinthiscase:

name,email,andjob.Thefield_data_typeiswhattypeofinformationwillbestored.ThedifferentformatsavailablecanbefoundattheMySQLColumnTypesPage.Forourpurposes,we'

llusetheVARCHARdatatypeforallofourfields.VARCHARisoneofthesimplestofdatatypeswhenitcomestoworkingwithstrings.sizeishowmuchofdataasinglefieldwillstore.Inthiscase,we'

lluse128.ThismeansthatthefieldcanhaveVARCHARdatathatis128bytes.Youcansafelythinkofthisas128charactersforthetimebeing,thoughthereisasomewhatmoretechnicalexplanationthattheabovesitewillprovideyouwith.Nowthatweknowhowwearegoingtocreatethetable,let'

sdoit.

3.3:

Creatingourtable

CREATETABLEdevelopers(nameVARCHAR(128),emailVARCHAR(128),jobVARCHAR(128));

QueryOK,0rowsaffected(0.11sec)

Lookslikeourtablewascreatedok.Let'

scheckitwiththeSHOWTABLEScommand:

3.4:

Verifyingourtable

+------------------+

|Tables_in_gentoo|

|developers|

1rowinset(0.00sec)

Yes,there'

sourtable.However,itdoesn'

tseemtohaveanyinformationonthetypesoffieldswesetup.Forthat,weusetheDESCRIBEcommand(orDESCforshort),whichtakesthenameofthetableasitsargument.Let'

sseewhatthatgivesusforourdeveloperstable.

3.5:

Describingourdeveloperstable

DESCRIBEdevelopers;

+-------+--------------+------+-----+---------+-------+

|Field|Type|Null|Key|Default|Extra|

|name|varchar(128)|YES||NULL||

|email|varchar(128)|YES||NULL||

|job|varchar(128)|YES||NULL||

Thisshowsthedifferentfieldsandtheirtypes.Italsoshowsafewextraattributesthatarebeyondthescopeofthishowto.FeelfreetorefertotheMySQLReferenceManualformoreinformation.Wenowhaveatabletoworkwith.Nowlet'

sgoaheadandpopulateit.

PopulatingOurMySQLDatabase

Wepopulateatable(oradddata)usingtheINSERTcommand.LiketheCREATETABLEcommand,italsohasaspecificformat:

3.6:

INSERTSyntax

INSERTINTOtable(col1,col2,...)VALUES('

value1'

'

value2'

...);

Thiscommandisusedtoinsertarecordintotable.tablecont

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

当前位置:首页 > 考试认证 > 从业资格考试

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

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