DB2 : DB user creation steps.
In Db2, you don’t directly create database users inside the database.
Db2 relies on operating system (OS) or LDAP users for authentication — and then you grant them access inside the database.
Step 1. Create the OS user
On Linux/Unix using root:
For example:-
useradd -d /opt/manoj/dbdata/testdb2 testdb2
passwd testdb2
Step 2. Connect to the Db2 instance as instance owner
Example (if instance owner is db2inst1):
su - db2inst1
db2 connect to db2db
Step 3. Grant privileges to that user
Once the OS user exists, you grant database privileges:
Grant connect privilege
db2 "GRANT CONNECT ON DATABASE TO USER testdb2"
Optional: Grant other roles if assinged in source db.
For example:
db2 "GRANT MAXIMO_READ ON DATABASE TO USER db2user1"
Etep 4. Update the .bash_profile on the server with db2profile location.
[testdb2@hostname ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
. /opt/manoj/dbdata/db2inst1/sqllib/db2profile
Step 5. Verify the connectivity
Then testdb2 can log in:
su - testdb2
db2 connect to db2db user testdb2 using <password>
Comments
Post a Comment