Thursday, April 10, 2014

DB2 database and User Privileges

IBM DB2 is a family of database server products developed by IBM. Here I was connecting DB2 and WSO2 products. Here I am show creating user and granting privilages for DB2 user.

Here I have two user one is 'madhuka' and and second user is 'db2test1'. Madhuka have all the right (admin). db2test1 is standard user. I have db2 database called 'regdb7'

Here I am try to connect to regdb7 from user 'db2test1'

db2 => connect to regdb7 user db2test1
Enter current password for db2test1:
SQL1060N  User "DB2TEST1" does not have the CONNECT privilege.  SQLSTATE=08004

 

image

db2test1 user do not have privilege to connect to regdb7

Now user 'madhuka' (admin) connect to db and give priviladges to db2test1 user

db2 => connect to regdb7 user madhuka using <password>

   Database Connection Information

Database server        = DB2/NT64 10.5.1
SQL authorization ID   = MADHUKA
Local database alias   = REGDB7

image

Here pass user grants

db2 => GRANT CONNECT ON DATABASE TO USER db2test1
DB20000I  The SQL command completed successfully.

image

then quit

now try connect from db2test1

db2 => connect to regdb7 user db2test1
Enter current password for db2test1:

   Database Connection Information

Database server        = DB2/NT64 10.5.1
SQL authorization ID   = DB2TEST1
Local database alias   = REGDB7

image


Yap, you are in

You can revoke the permission from

db2=> REVOKE CONNECT ON DATABASE FROM USER db2test1

Here is we try out

image

 

Here is full use case that we try

image

Here is privilege list to try

[1] http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=%2Fcom.ibm.db2.luw.admin.sec.doc%2Fdoc%2Fc0005478.html

No comments:

Post a Comment