1.首先下载IBM的IBM Data Server Client
2.安装好客户端之后,打开cmd,运行db2cmd。然后在db2cmd中执行以下步骤。
第一步,创建节点
语法:db2 catalog tcpip node remote server
例子:db2 catalog tcpip node MyNode remote 10.18.1.120 server 50002
第二步,创建远程数据库实例
语法:db2 catalog db as at node
例子:db2 catalog db RemoteDBName as MyDBName at node MyNode
第三步,连接数据库
语法:db2 CONNECT TO user using
例子:db2 CONNECT TO MyDBName user username using pssword (用户名和密码是远程server的用户名和密码)
示例:
db2 => catalog tcpip node mynode remote 10.18.1.120 server 50002
db2 => catalog db remoteDBName as MyDBName at node mynode
db2 => connect to MyDBName user db2inst1 using db2inst1 (用户名和密码是远程server的用户名和密码)