How to connect with DB2 client in windows.?

2.8k views Asked by At

I have installed 'DB2 data server client' on my machine. I want to connect to it and execute the shell script, but i am getting error DB21061E Command line environment not initialized , when i am executing shell script and trying to connect with it. I have installed DB2 version '11.5' and Fix Pack "0". what should be the fix for this?

enter image description here

enter image description here

1

There are 1 answers

0
mao On

This is a frequently asked question.

If you are running on Microsoft-Windows then you either run scripts for Db2 in a db2cmd.exe window, or set the environment variable DB2CLP correctly before running your scripts.

For Microsoft-Windows, You can run db2cwadmin to open the db2cmd.exe window. This window will already have the environment variable DB2CLP set. You can also directly run the db2cmd.exe program if db2cwadmin is not available.

For Powershell: set-item -path env:DB2CLP -value "**$$**"

Apart from setting the DB2CLP environment variable, and/or using the db2cmd.exe window, you then need to perform additional configuration steps called "catalog node" and "catalog database" before you will be able to connect via command-line or db2-clp.

If the Db2 database server is remote (not on your machine), then you need to catalog the node to tell the Db2-client about the hostname-port for the Db2-server. db2 catalog tcpip node see documentation here, followed by the command db2 terminate.

IF you do not want to catalog, then you can still connect at the command line but with the [clpplus][2] tool (a java application), which accepts a connection-string and allows an Oracle SQL*plus style interface to Db2 databases.

If the Db2-node is already catalogued correctly, or if the database is local (on the same hostname as your Db2-client), then you need to run db2 catalog database... command, see documentation here and then run db2 terminate.