Installing DB2 on Mac OS X

It’s useful to have a local installation of the DB2 on Mac for development and test purposes. I have a local installation on my Macbook to develop DB2-backed Ruby on Rails applications.

IBM DB2 is a mature relational database server. It supports lots of neat things like SQL, XQuery for XML, SPARQL for RDF, full text search, and so on.

DB2 on Mac using DockerDB2 on Mac logo

A quicker option for getting running with DB2 on Mac is to use the DB2 docker image. It should get you started quickly with DB2 by running it in a virtualized Linux environment on your Mac.

DB2 on Mac natively

Here are the current instructions for installing DB2 10.1 on Mac OS X, courtesy of my colleague Kevin Rose:

Instructions to install DB2 v10.1 on Mac OS X Yosemite:

Prerequisite: XCode developer tools must be installed. These can be installed from the Mac App Store.

1. Ensure the following entries are in the /etc/sysctl.conf. Create the file /etc/sysctl.conf if it does not exist.


Restart your Mac after creating the file to make the values take effect.

2. Open a terminal with a shell for the the user that will become instance owner.

3. Ensure that otool is in the path. Execute otool:


If the error is “command not found” then run the following

     export PATH=$PATH*:*/Applications/

4. Extract the DB2 install image from the tar archive:

     tar -xzvf db2_v101_macos_expc.tar.gz

The image will be extracted into an expc directory.

5. Enter the expc directory and run the installer and perform a non-root install:

     cd expc
  # *** DO NOT RUN db2_install AS ROOT ***

This will install DB2 to the following default location: /Users/$(whoami)/sqllib

Execute step 6 if you need to enable connections for a userid other than the instance owner:

6. Enable OS authentication. (You need to be an Admin user to run these commands):

cd /Users/$(whoami)/sqllib/security
sudo chown root /Users/$(whoami)/sqllib/security/db2ckpw
sudo chmod u+rxs /Users/$(whoami)/sqllib/security/db2ckpw 
sudo chmod o+rx  /Users/$(whoami)/sqllib/security/db2ckpw

The instructions for starting DB2 and configuring remote access are the same as before.

3 thoughts on “Installing DB2 on Mac OS X

  1. Hello Leons,

    I’m trying to install DB2 on a Mac El Capitan and I’ve followed the instructions from this post:

    Now, I’m having a problem at step 11 in the If statement. When executed in the .zshrc profile, I’m loosing the $PATH var entirely and the “unknown commands” follows everything I type at the iTerm.

    The steps up to 10 are executed seamlessly.

    Can you please help me a little? I mean I red also the present article but I’m kind of confused since the initialization of a sample db instance is not working at all and I don’t know how to proceed.

    This is the output when > db2sampl is running:
    – Starting the DB2 instance…
    – Creating database “SAMPLE”…
    – Attempt to create the database “SAMPLE” failed.
    – SQL1032N No start database manager command was issued. SQLSTATE=57019

    Thank you very much.



    1. It’s been a long time since I’ve worked with DB2.

      Can you try checking your .zshrc using I suspect there’s something wrong with the PATH=$PATH:/opt/IBM/db2/V10.1/bin line.

      I recommend running DB2 in a Docker container rather than natively.


  2. Good Mornign Leons,

    I’ve uninstall everything and I’ll try the docker path. The thing is that my docker is really old (as my machine) it’s not even the Desktop version so I hope to not having any issues there.

    Tell me something If I might ask: Why IBM is not building a binary (.dmg) for the Macs? I mean, that thing they promoting “LUW” is a pretty clear statement for me that “we’re not interested about Macs and you should me pretty lucky if DB2 is working there at all”.

    Anyway, I’ll let you know.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.