IBM Support

How to change DB2 user password?

Question & Answer


Question

How to change DB2 user password?

Answer

User IDs and passwords for DB2 are managed at OS level. However, passwords can also be changed when connecting to databases.
To enable support for changing passwords in the Db2® database products on Linux® or AIX®, you must configure the Db2 instance to use Transparent LDAP.
For example, use the CONNECT statement to change the password as the following,
 
db2 "CONNECT TO <database> USER <userid> USING <password> NEW <new_password> CONFIRM <new_password>"

For JDBC, there's a method for DB2Connection interface, changeDB2Password.

For CLI, change password with the CLI function SQLDriverConnect. This can be done with the Interactive CLI Sample Program which can be brought up by running "db2cli" command. For example, run the following with db2cli interface,
 

opt calldiag on
sqlallocenv
sqlallocconnect 1 1
sqldriverconnect 1 0 "database=<dbname>;hostname=<hostname>;port=<port>;protocol=tcpip;uid=<uid>;pwd=<oldpwd>;newpwd=<newpwd>" -3 512 SQL_DRIVER_NOPROMPT

[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"ARM Category":[{"code":"a8m500000008PmmAAE","label":"Security and Plug-Ins-\u003EAuthentication"}],"ARM Case Number":"","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"All Versions"}]

Document Information

Modified date:
16 August 2023

UID

swg21984232