If you're working with IBM Db2 on a Windows Server environment, it's important to note that unlike MySQL, Db2 does not manage users internally. Instead, it relies on operating system–level users for authentication and authorization. Below is a step-by-step guide to create a new database and its corresponding user in Db2 on Windows.
🧱 Step 1: Create a New
Database in Db2
Open the Db2 Command Line Processor (CLP) as
Administrator and run the following command:
db2 create database BCIDB
This will create a new database named BCIDB.
👤 Step 2: Create a System
User for Database Access
Since Db2 uses OS-level users, we need to create a new local
Windows user that will be granted access to the database.
- Go to Computer
Management
- Navigate
to: System Tools → Local Users and Groups → Users
- Right-click
on Users and select New User.
- Enter
the username as BCIUser and set a strong password.
⚙️ Step 3: Activate and Configure
the User via Command Prompt
Open Command Prompt as Administrator and run the
following commands:
net user BCIUser /active:yes
net user BCIUser "YourPasswordHere"
net user BCIUser
The last command will display the user properties. Ensure
that:
- The account is active
- Password is not expired or restricted
🛡️ Step 4: Grant Database
Permissions to the User
Now connect to the Db2 database and assign administrative
privileges to the newly created user:
db2 connect to BCIDB
db2 grant dbadm on database to user BCIUser
🔄 Step 5: Reset the
Connection
After granting permissions, reset the Db2 connection:
db2 connect reset
✅ Summary
You’ve now successfully:
- Created
a Db2 database (BCIDB)
- Created
a corresponding OS-level user (BCIUser)
- Activated
and configured the user
- Granted
necessary database privileges
This method ensures secure and OS-authenticated access to
Db2 databases on Windows Server platforms.
🔁Note: Always ensure your user passwords are secured and stored according to your organization’s password policy.