您可以从 CLP 首先ATTACH
使用所需的任何用户 ID 访问实例,然后发出CREATE DATABASE
命令。
如果实例在您的本地机器上运行,您只需像这样附加:
$ db2 attach to db2inst1 user db2inst1
Enter current password for db2inst1:
Instance Attachment Information
Instance server = DB2/LINUXX8664 9.7.5
Authorization ID = DB2INST1
Local instance alias = DB2INST1
如果实例在远程服务器上运行,则附加到您在数据库目录中定义的“节点名称”:
$ db2 list db directory
System Database Directory
Number of entries in the directory = 1
Database 1 entry:
Database alias = SAMPLE
Database name = SAMPLE
Node name = SRV01
Database release level = d.00
Comment =
Directory entry type = Remote
Catalog database partition number = -1
Alternate server hostname =
Alternate server port number =
在此示例中,输出中显示的节点名称list database directory
是SRV01
,因此您可以使用: 附加 db2 attach to srv01 user <username>
。