ODBC can be a solution to your portability needs, but unfortunately it is not as easy to set up an ODBC connection on Linux as it is on Windows. This tutorial attempts to shed some light on this process by guiding you towards adding an ODBC driver on Ubuntu. The process described below has been tested on Ubuntu 8.04 and Ubuntu 8.10.
![]()
BackgroundRecently I’m kinda of fancy with Nodejs, but as you know that nodejs doesn’t support many RDBMS. I know node can connect to and but definitely not HANA, since no one write a drive base on hana database. I’m not an expert of HANA and even Nodejs, so write a drive of HANA is beyond my knowledge. So I decide to connect HANA on my Ubuntu through odbcBut I encountered lots of problems when I was trying to accomplish the job that I think it’s simple enough, but actually it take me four hours to figure it out how to. I decided to document it just in case someone else need to configure HANA with odbc and maybe it can save you times. 1.Install HANA Client on LinuxMy environment is Ubuntu 12.04, connect HANA via Windows is easy and well. I highly recommend you to install HANA client on your Ubuntu, because you test and debug your connection with HANA.
I wrote another and share you how to install it. My installation is under /opt/sap/hdbclient, if the HANA client was successfully installed.
Execute command./hdbsql under /opt/sap/hdbclient you will getethanz@ubuntu:/opt/sap/hdbclient$./hdbsqlWelcome to the SAP HANA Database interactive terminal.Type: h for help with commandsq to quithdbsql=You can test your connection first by typing following command, now I’m connecting to our modeling server which is a testing environment.hdbsql= c -n your-hana-server -u username -p secretConnected to VS5@xml1009:30015hdbsql VS5= 2, Install unixodbc and odbcinst on UbuntuBefore you connect to HANA via odbc, first make sure the odbc and odbc client was installed. Odbcinst is the command tool to manage your DSN entry. Unixodbc is used to connect actual database.Install odbc and odbcinst by following commandsudo apt-get install unixodbc unixodbc-devsudo apt-get install odbcinst 3,Edit your ODBC EntryAfter successfully install unixodbc, system will create two blank ini files /etc/odbc.ini and /etc/odbcinst.ini. Go ahead edit /etc/odbc.ini with your favorite text editor and the input like followings:hanaDriver = /opt/sap/hdbclient/libodbcHDB.soServerNode =hana-server-name:30015I don’t know why the configuration is totally different with others (like MySQL). Be careful with the key of ServerNode. It’s not Host or Server, the key is ServerNode, otherwise odbc will try to connect to your localhost and always get connection errors. And I found the username and password in the odbc.ini file does NOT work, so you don’t need them at all.
4, Test your connectionAfter step 3, you are almost done, now let’s test your connection and how does it work. In your terminal, typeisql hana username passwordIf you see following responses, congratulationsethanz@ubuntu:$ isql hana username password+—————————————+ Connected!
sql-statement help tablename quit +—————————————+SQL 5, Connect hana via Python with odbc.Write a simple test script and see how it’s workimport pyodbcconn = pyodbc.connect(‘DSN=hana;UID=username;PWD=password’)print connIf there’s no exception throw out and you can see the connection print out, congrats. 6, ConclusionSeveral things need wrap up, one thing is the configuration key, it’s ServerNode instead of Host/Server. Another thing is you have to implicitly to provide the username and password in your connection string or terminal isql command.Last thing to remember, if you install pyodbc via pip like sudo pip install pyodbc, make sure you have installed python-dev, otherwise the compilation will fail.sudo apt-get install python-dev && sudo pip install pyodbcOk, fellows, that’s it. Good luck with your HANA journey.
In the year 2016, Microsoft surprised the IT world with the announcement of their plans to bring MS SQL Server to Linux.
Under Satya Nadella’s leadership, the Redmond giant has made significant progress towards taking advantage of the areas where Linux dominates the industry (such as the technologies that power the cloud). The move to make SQL Server available in Linux is yet another indicative of this approach.
![]()
Whatever the company’s motivations behind this initiative, Linux system administrators are likely to need to learn how to install, maintain, and use MS SQL Server – especially considering that the preview version packages are already available for Red Hat Enterprise Linux 7.3+ (includes CentOS 7.3+ as well) and Ubuntu Server 16.04 bits (sorry – no 32-bit version available!).
![]()
The only “fancy” system requirement of the preview version is that the system where it is installed must have at least 2 GB of RAM.
Installing MS SQL Server on Linux
In this quickstart article, we will explain how to install SQL Server 2019 preview on RHEL/CentOS 7.3+ releases and Ubuntu 16.04.
Installing MS SQL Server on RHEL/CentOS 7.3+
1. To install SQL Server on RHEL/CentOS 7.3+ releases, download the Microsoft SQL Server 2019 preview Red Hat repository configuration files, which will install the mssql-server package and mssql-tools using the following curl commands.
2. Then install the SQL Server and mssql-tools with the unixODBC developer package using yum package manager, as shown.
3. When the installation is complete, you will be reminded to run the configuration script (/opt/mssql/bin/mssql-conf) to accept the license terms, set the password for the SA user, and choose your edition.
4. Once the configuration is done, verify that the SQL Server service is running.
5. Open port 1433/tcp on your firewall in order to allow external clients to communicate with the database server:
If you’re using firewalld:
Otherwise (using iptables):
Installing MS SQL Server on Ubuntu 16.04
1. In order for Ubuntu to trust the packages from the MS SQL Server repositories, import the GPG keys using the following wget command.
2. Add the Microsoft SQL Server Ubuntu repository for SQL Server 2019 preview.
3. Resynchronize the package index files and update the core package and additional tools:
4. Run the configuration script as in the previous case:
5. Choose “Yes” when prompted to accept the license terms for MS SQL Tools:
Configuring MSSQL Tools on Linux
Testing MS SQL Server on Linux
We will login to the server and create a database named Fabrics. The
-P switch must be followed by the password you chose when you installed the package previously:
If you’re using Linux, you can continue using the command-line as shown above. Otherwise, install SQL Server Management Studio Express if you’re on Windows.
Once done, enter the IP of the database server (192.168.0.200 in this case) and the login credentials (username=sa, password=YourPasswordHere):
Connect to MSSQL Server
Upon successful login, the Fabrics database should appear at the left-hand side:
Next, click New Query to open a new query window where you’ll insert the contents of the Fabrics script from Codeproject.com, then click Execute.
If successful, you will see the script created 5 tables and the number of records in each:
Create a Sample SQL Database
To wrap up, run the following query to retrieve the first 5 records from the Clients table:
The results should be identical to the output in the following image:
Congratulations! You have successfully installed and tested MS SQL Server on Linux!
Summary
In this article, we have explained how to install MS SQL Server on RHEL / CentOS and Ubuntu Server.
Due to the newfound closeness of Microsoft and Linux, Linux system administrators will need to be knowledgeable on MS SQL Server if they want to stay at the top of their game.
By mid-2017, the same SQL Server editions will be offered on Linux as today on Windows: Enterprise, Standard, Web, Express, and Developer. The last two are free but only the Express edition will be licensed for production use (but with resource limits).
As always, feel free to use the comment form below to drop us a note if you have any questions. We look forward to hearing from you!
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2023
Categories |