Using DB2

Getting your own version of DB2

Installing DB2 Express-C version 10.1 on Ubuntu

  1. Download DB2 Express-C.
  2. Extract the downloaded package (that is, db2_v101_linuxx64_expc.tar.gz, or the equivalent downloaded version).
  3. Open a terminal and navigate to the extraction directory.

    Note: There are some limitations for installing DB2 as non-root user. So, it is better to switch to root user (using "su root" command) first before installing DB2.

  4. Start the DB2 Setup Launchpad by running ./db2setup

    Note: If you get any missing libraries errors, do not run ./db2setup -f sysreq to force installation; instead, install the missing libraries first. You can use synaptic package manager on Ubuntu to get those libraries. For instance, the setup tool seems to require the package rpm.

    Note: If you start the setup as root user, you may get the following error: "Can't connect to X11 window server using ':0' as the value of the DISPLAY variable." In this case, open another terminal and (as the normal user) run the following command:  xhost +

  5. In the DB2 Setup Launchpad select "Install a Product" (from the left menu).
  6. Press the "Install New" button. Another wizard will pop up.
    1. Click the "Next" button.
    2. Accept the license agreement.
    3. Select the custom installation type.
    4. Select the "Install DB2 Express-C on this computer" option.
    5. "Select all" features (to include the Application Development tools).
    6. Select additional languages if you wish.
    7. Documentation: Just click the "Next" button.
    8. DAS user: Enter a user name and password.
    9. Create a DB2 instance.
    10. Set owner user for the DB2 instance to be created. Note, you will not be allowed to select the same user as the DAS; so create a new user. This is the account that you will use to run DB2.
    11. Set fencing users for the DB2 instance to be created. You can leave it to the default entries; just write a password.
    12. Communication and startup: Accept the given configuration (just click "Next") // Select "Do not configure at this time" (it is not necessary for remote clients to access your DB2 instance).
    13. Notification setup: Select "Do not set up your DB2 server to send notifications at this time."
    14. DB2 Text Search: Select "Do not configure at this time."
    15. Click the "Finish" button.
  7. The installation process may take some time. Eventually, it should finish with a dialog that shows the setup log. Check the log to ensure everything was set up successfully.
  8. Finally, click the "Finish" button.
  9. If you ran  xhost +  before (see above), then do not forget to run  xhost -  now.
  10. To test DB2 using the SAMPLE database do the following:
    1. Log in as the DB2 instance owner (db2inst1 by default).
    2. Create the SAMPLE database by running the command  db2sampl  (in a terminal). This may take some time.
    3. After the database has been created, start the DB2 command line interface using the command:  db2
    4. Connect to the SAMPLE database using the command:  connect to sample
    5. Issue SQL statements, e.g.  select * from staff
    6. Exist the DB2 command line interface using the command:  quit

Installing DB2 Express-C version 9.7 on Windows

Note, I have not tested the following installation steps because I do not have a Windows machine. I have just copied these steps from previous year's. Please let me know if the steps need adjustment (and what these adjustments are).

  1. Download DB2 Express-C.
  2. Click on Launch and follow the instructions. This unzips the files and starts a Setup wizard.
  3. Select "Install a Product" (from the left menu).
  4. Press "Install New". This should install DB2 Express-C.
  5. Another wizard will pop up; follow its instructions.
  6. Click next; accept license agreement.
  7. Select "typical installation".
  8. DAS User Information: Enter a user name and password.
  9. After Next and Finish, the installation will begin.
  10. When asked, create the DB2 First Steps profile.
  11. First Steps will launch a browser page.
  12. There are no updates to download.
  13. Click the button to create the sample database.
  14. To test DB2 using the SAMPLE database do the following:
    1. Open the DB2 "command window" that should be available from Start -> All Programs -> IBM DB2.
    2. Start DB2 command line interface by entering the command:  db2
    3. Connect to the SAMPLE database using the command:  connect to sample
    4. Issue SQL statements, e.g.  select * from staff
    5. Exist the DB2 command line interface using the command:  quit

Dec. 4, 2012. Olaf Hartig