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. 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


[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Database Objects\/Config - Database","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"10.1;10.5;9.7","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
16 June 2018

UID

swg21984232