安装完成后,欲登陆sample数据库和toolsdb,发现出错:

    db2=>connecttosample SQL1031NThedatabasedirectorycannotbefoundontheindicatedfilesystem. db2=>connecttotoolsdb SQL1031NThedatabasedirectorycannotbefoundontheindicatedfilesystem.

1、猜想数据库未安装,查看/hom/db2inst1目录下的,仅有sqllib文件夹:

    [db2inst1@localhost~]$ls sqllib

对比下其他学员的情况,发现本人的服务器上少了一个db2inst1目录:

    [db2inst1@localhost~]$ls b2inst1sqllib

2、下面手动对两个数据库进行创建:

2.1、创建示例数据库:

    [db2inst1@localhost~]$db2sampl Creatingdatabase"SAMPLE"... Connectingtodatabase"SAMPLE"... Creatingtablesanddatainschema"DB2INST1"... CreatingtableswithXMLcolumnsandXMLdatainschema"DB2INST1"... 'db2sampl'processingcomplete.

2.2、创建toolsbd数据库:

    [db2inst1@localhostNODE0000]$db2createtoolscatalogsystoolscreatenewdatabasetoolsdb DB20000ITheCREATETOOLSCATALOGcommandcompletedsuccessfully.

2.3、确认相应数据库文件创建的情况:

    [db2inst1@localhostNODE0000]$cd [db2inst1@localhost~]$ls db2inst1sqllib [db2inst1@localhost~]$cddb2inst1/ [db2inst1@localhostdb2inst1]$ls NODE0000 [db2inst1@localhostdb2inst1]$cdNODE0000/ [db2inst1@localhostNODE0000]$ls SAMPLESQL00001SQL00002sqldbdirTOOLSDB

2.4、登陆数据库。首先登陆到sample,然后断开与该数据库的连接,再连接到toolsdb:

    [db2inst1@localhostNODE0000]$db2 (c)CopyrightIBMCorporation1993,2007 CommandLineProcessorforDB2Client9.7.1 YoucanissuedatabasemanagercommandsandSQLstatementsfromthecommand prompt.Forexample: db2=>connecttosample db2=>bindsample.bnd Forgeneralhelp,type:?. Forcommandhelp,type:?command,wherecommandcanbe thefirstfewkeywordsofadatabasemanagercommand.Forexample: ?CATALOGDATABASEforhelpontheCATALOGDATABASEcommand ?CATALOGforhelponalloftheCATALOGcommands. Toexitdb2interactivemode,typeQUITatthecommandprompt.Outside interactivemode,allcommandsmustbeprefixedwith'db2'. Tolistthecurrentcommandoptionsettings,typeLISTCOMMANDOPTIONS. Formoredetailedhelp,refertotheOnlineReferenceManual. db2=>connecttosample DatabaseConnectionInformation Databaseserver=DB2/LINUX9.7.1 SQLauthorizationID=DB2INST1 Localdatabasealias=SAMPLE db2=>disconnectsample DB20000ITheSQLDISCONNECTcommandcompletedsuccessfully. db2=>connecttotoolsdb DatabaseConnectionInformation Databaseserver=DB2/LINUX9.7.1 SQLauthorizationID=DB2INST1 Localdatabasealias=TOOLSDB

【编辑推荐】

    在DB2中正确导出LOB数据DB2外部文件格式浅析DB2数据库设计的三个建议解析DB2与非DB2数据库之间远程复制 DB2数据库基本操作指令30条