top of page

How to connect to DB2 database remotely

  • Writer: Jha Chandan
    Jha Chandan
  • Jan 11, 2021
  • 1 min read

Catalog the node

Syntax: db2 catalog tcpip node <NODENAME> remote <REMOTE> server <PORT>

C:\Program Files\IBM\SQLLIB\BIN> db2 catalog tcpip node server1 remote 192.168.6.141 server 50000

DB20000I The CATALOG TCPIP NODE command completed successfully. DB21056W Directory changes may not be effective until the directory cache is refreshed.


Catalog the database

Syntax: db2 catalog database <database_name> at node <node_name>

C:\Program Files\IBM\SQLLIB\BIN> db2 catalog database sampledb at node server1

DB20000I The CATALOG DATABASE command completed successfully. DB21056W Directory changes may not be effective until the directory cache is refreshed.


Refresh directory

C:\Program Files\IBM\SQLLIB\BIN> db2 terminate

DB20000I The TERMINATE command completed successfully.


Connect to database

Syntax: db2 connect to <database_name> user <user_name> (you will then be prompted for a password)

C:\Program Files\IBM\SQLLIB\BIN> db2 connect to sampledb user db2admin using P@ssw0rd

Database Connection Information Database server = DB2/NT64 9.7.6 SQL authorization ID = DB2ADMIN Local database alias = SAMPLEDB

C:\Program Files\IBM\SQLLIB\BIN> db2 list tables

Table/View Schema Type Creation time ------------------------------- --------------- ----- -------------------------- 0 record(s) selected.



Verify catalog database


C:\Program Files\IBM\SQLLIB\BIN> db2 list db directory

System Database Directory

Number of entries in the directory = 1

Database 1 entry:

Database alias = SAMPLEDB Database name = SAMPLEDB Node name = SERVER1 Database release level = d.00 Comment = Directory entry type = Remote Catalog database partition number = -1 Alternate server hostname = Alternate server port number =

C:\Program Files\IBM\SQLLIB\BIN> db2 list node directory show detail

Node Directory

Number of entries in the directory = 1

Node 1 entry:

Node name = SERVER1 Comment = Directory entry type = LOCAL Protocol = TCPIP Hostname = 192.168.6.141 Service name = 50000 Remote instance name = System = Operating system type = None

Note : Don't forget to use "db2 terminate" after you execute catalog and uncatalog

Comments


jc_logo.png

Hi, thanks for stopping by!

Welcome to my “Muse & Learn” blog!
Muse a little, learn a lot.✌️

 

Here you’ll find practical SQL queries, troubleshooting tips with fixes, and step-by-step guidance for common database activities. And of course, don’t forget to pause and muse with us along the way. 🙂
 

I share insights on:​​

  • Db2

  • MySQL

  • SQL Server

  • Linux/UNIX/AIX

  • HTML …and more to come!
     

Whether you’re just starting out or looking to sharpen your DBA skills, there’s something here for you.

Let the posts
come to you.

Thanks for submitting!

  • Instagram
  • Facebook
  • X
2020-2025 © TechWithJC

Subscribe to Our Newsletter

Thanks for submitting!

  • Facebook
  • Instagram
  • X

2020-2025 © TechWithJC

bottom of page