IBM Support

DB21061E environment not initialized when running DB2 commands in the Windows command line



When attempting to run any commands in the Windows command line, as in the following example, an error message is displayed: DB21061E Command line environment not initialized


The user is unable to connect to the DB2 database.


The environment variable DB2CLP is not set correctly

Diagnosing The Problem

As an example: attempt to connect to the database:

C:\programdata\IBM\DB2\DB2TSM1\SERVER1>db2 connect to MYDB

This will fail with "DB21061E Command line environment not initialized"

Resolving The Problem

Run the following command to set the DB2 command line (DB2CLP) variable:
db2cmd -i -w db2clpsetcp

Check that the DB2CLP variable has been set correctly:
echo %DB2CLP%

This should now show:

Once this is done, the db2 connect command should work properly

Related Information

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Operating System \/ Hardware - OS Configuration","Platform":[{"code":"PF033","label":"Windows"}],"Version":"9.7;9.5;10.1;10.5","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
16 June 2018