Database name not found but I can connect using IBM Data Studio. What happened? In IBM Data Studio, I can create a connection to a remote IBM DB2 LUW database named DBEMP and browse the schema and data.

Here is the steps to create the database connection:


From IBM Data Studio, In Database Adminstration Explorer, select: New -> New Connection to Database.
Select DB2 for Linux, UNIX, and Windows in the dialog.
In General properties:

Database: DBEMP
Host: 10.221.5.111
Port Number: 50001
User Name: user1
Password: *
Click OK.



But when I tried to connect to the remote database server (AIX v7) via telnet command:

telnet 10.221.5.111


Note: I login using root user.

And then I run this command:

/db2/V10.1/bin/db2 connect to DBEMP


I got this error:


  SQL1013N  The database alias name or database name "DBEMP" could not
  be found. SQLSTATE=42705


Then I also run this command:

/db2/V10.1/bin/db2 list database directory


The result list doesn't have database named "DBEMP".


So what happened anyway?

If there is no database name exist, why IBM Data Studio can connect to it?
Ahh....That has to do with profiles. Root was not set up by default to have DB2 libraries set up in its profile, so it doesn't recognize the DB2 executables. This is not to say root can't do what you are asking, you would just have to browse to the /instance/bin folder to find the executables you are after. Of course, then you have to worry about whether or not root has permission to connect....

But anyway, you might find it easier to sudo over to the id you want to use to connect (possibly even the instance) sudo - myid. For sure the instance will have DB2 set up in its profile. Your other ID you may have to set it up. Here is an answer I provided before where I showed someone how to set up DB2 for their profile.

I would recommend that you not give root DB2 access through its profile.