Showing posts with label Informix. Show all posts
Showing posts with label Informix. Show all posts

Sunday, November 15, 2015

How to connect to informix db without username & password (Enable trusted connection)

IBM Informix DB supports trusted connections where you do not want to provide a user name and password when connecting to the DB. You can refer my previous blog from here to get started with informix from here. So lets see how we can make a trusted connection in informix and how to connect to the DB.

Step 1 Create a trusted connection in informix DB


For this you will need the ip of the connection that will try to connect to the DB and the user name of that respective connection. So in my example the details is as follows,

  1. IP - 192.168.1.5
  2. User - Simple
Launch a server instance and access the instance via "dbaccess". Navigate to "Query - Language" then you will be asked for a database to select. Select one of your desired databases and press "Enter". Now click on "New", you will be taken to the "Query Editor" (Refer below pic)


Now first grant permission to the user to enable him to grant privileges to create trusted connections for that you can use the following query,



1) GRANT DBSECADM TO {INFORMIX_USER};

Now that we granted the user permission to create trusted connections now lets look at the sample query that will enable informix to identify a user who is trying to connect to the DB without providing a username and password in the connection string.


2 ) CREATE TRUSTED CONTEXT tcx1 USER Sample ATTRIBUTES (ADDRESS '192.168.1.5') ENABLE;

3) GRANT CONNECT TO Sample;

In query 2 "Sample" is the username that I am going to provide permission to connect without providing a username and password. The address 192.168.1.5 is the address that the user will try to connect to the DB. Query 3 is to grant permission regarding to connection for the server. After executing the above two queries we have now configured user "Sample" to connect without username and password.




Step 2 Connect and test the trusted connection without credentials


I will be using DBeaver as the DB client to test this connection. DBeaver is a universal db connection tool which can be downloaded from here.

Now run the DBeaver client and create a new informix connection and provide the connection details as below.

jdbc:informix-sqli://192.168.1.5:9093/{DB_NAME}:INFORMIXSERVER={SERVER_NAME};TRUSTED_CONTEXT=TRUE


Now test the connection without providing a user name and password. You will be successfully connected to the DB(refer below pic).







Wednesday, October 28, 2015

Creating databases and testing the connection of a IBM Informix DB


This blog post will be mainly focused on how to start / stop the informix server. Create a database and table etc.


Login from informix user and run the server instance


Login with the informix windows user that was created during the installation and simply search for informix under start and you will find a server instance similar to "ol_informix1210". Run the server instance as Administrator.


Basic commands to get started with informix


Run the below commands in the cmd that was open.
  • Start informix server - oninit -ivy
  • Shut down informix server - onmode -ky
  • Check server status   - onstat -g dis

Create Informix DB



Use the command "dbaccess" cmd to navigate to db creation section. You will be getting the following options.




Navigate to Database  - > Create

Provide a suitable name for the database which needs to be created.



Select a DB space

After selecting a DB space select  "Create-new-database" and click enter. This will create the new database.




Create a table


Select the DB that was created and go to tables section the select "Create" and provide a table name.



Add columns as your requirement refer below pic to get an idea.



Once you are done select "Build-new-table" this will create the table.


Connect and test the informix DB created


You can use a client like DBeaver to connect to the database you created. You have to provide the host, Port, server,database/Schema, username and password in order to connect to the server.

NOTE - Informix by default binds a ipv6 for the port. So to connect to the db follow the below sample.

* You can use a simple tool such as cports to view the ports and the address that it is bind to or you can use the command

netstat -a | findstr 'Port number' 


jdbc connection URL looks like this, which needs for the connection.

jdbc:informix-sqli://{hostip}:{port}/{DBName}:INFORMIXSERVER={InformixServerName}

jdbc:informix-sqli://fe80::f16e:99a8:22ca:682:9088/test:INFORMIXSERVER=ol_informix1210



Now you can view the table that was created via dbeaver client



Binding the Port to a IP V4  


After the installation you will be able to see a separate option called the 'IBM informix' in the start menu. You can create any number of server instances from the 'Server Instance Manager' tool under that option the Start Menu.




In informix you have the possibility to create a server with a IP V4 or IP V6. We can create a IP V4 from the 'Server Instance Manager'.

From there you will be asked to set a 'service name' and a 'port number'  while proceeding.  Set the desired values for these fields, So they can be referred lately.