{"id":606,"date":"2023-11-13T18:30:10","date_gmt":"2023-11-13T18:30:10","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2023\/11\/13\/8583784-how-to-connect-to-the-microsoft-sql-server-odbc-at-hostinger\/"},"modified":"2026-03-16T12:12:01","modified_gmt":"2026-03-16T12:12:01","slug":"8583784-how-to-connect-to-the-microsoft-sql-server-odbc-at-hostinger","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/8583784-how-to-connect-to-the-microsoft-sql-server-odbc-at-hostinger\/","title":{"rendered":"How to Connect to the Microsoft SQL Server (ODBC) at Hostinger"},"content":{"rendered":"<h2 id=\"h_2ed5b0a36f\">Step 1 &mdash; Check for the \/etc\/odbcinst.ini File<\/h2><p class=\"no-margin\">Check the <b>\/etc\/odbcinst.ini<\/b> file and make sure it includes information similar to the one below. You can check this using <b><a href=\"\/support\/1583245-how-to-connect-to-a-hosting-plan-via-ssh\" target=\"_blank\" class=\"intercom-content-link\">SSH<\/a><\/b>. Use the command <code>cat \/etc\/odbcinst.ini<\/code> for that:<\/p><p class=\"no-margin\">\n<\/p><pre><code>[FreeTDS] <br>Description = ODBC for FreeTDS <br>Driver = \/usr\/lib64\/libtdsodbc.so <br>Setup = \/usr\/lib64\/libtdsS.so.2 <br>Driver64 = \/usr\/lib64\/libtdsodbc.so <br>Setup64 = \/usr\/lib64\/libtdsS.so.2 <br>FileUsage = 1<\/code><\/pre><p class=\"no-margin\">You don&rsquo;t need to make any changes to this file. Only check if it exists and has data on it. If you cannot find this file, or it&rsquo;s empty, <b><a href=\"\/support\/1583780-how-to-contact-live-support\" target=\"_blank\" class=\"intercom-content-link\">contact us<\/a><\/b>.<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"h_21e2ecd44b\">Step 2 &mdash; Create a .odbc.ini File<\/h2><p class=\"no-margin\">Go to your website&rsquo;s <b><a href=\"\/support\/4548688-basic-actions-in-the-file-manager\" target=\"_blank\" class=\"intercom-content-link\">file manager<\/a><\/b>, and select the option to <b>access all the files of your hosting plan<\/b>:<\/p><p class=\"no-margin\">\n<\/p><div class=\"intercom-container intercom-align-center\"><img decoding=\"async\" src=\"\/support\/wp-content\/uploads\/sites\/55\/2023\/11\/9f4c0878-cf37-4e0f-b045-2ebfb3c78f46.jpg\" alt=\"Accessing the files of the whole hosting plan\"><\/div><p class=\"no-margin\">This way, you&rsquo;ll land in the root directory of your hosting plan. Here, create a <code>.odbc.ini<\/code> file:<\/p><p class=\"no-margin\">\n<\/p><div class=\"intercom-container intercom-align-center\"><img decoding=\"async\" src=\"\/support\/wp-content\/uploads\/sites\/55\/2023\/11\/d4b3436f-4cb2-4e40-b060-a9fd4a4a07fc.jpg\" alt=\"Creating a new file in the file manager\"><\/div><p class=\"no-margin\">Add the following text inside the file:<\/p><pre><code>[mssql_odbc] <br>Description = MSSQL Server <br>Driver = FreeTDS <br>Database = username_databasename <br>Server = mssql.database.servername.tld <br>Port = 1433<\/code><\/pre><p class=\"no-margin\">Replace the following as given below:<\/p><ol>\n<li>\n<p class=\"no-margin\"><code>username_database<\/code> &mdash; insert the <b>name of the SQL server database<\/b> to be used<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><code>mssql.database.servername.tld<\/code>  &mdash; insert the <b>hostname or IP address of the server<\/b> to connect to<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><code>1433<\/code> &mdash; insert the port that you&rsquo;ll use for the MSSQL connection; change this number only if your default port isn&rsquo;t <code>1433<\/code><\/p>\n<\/li>\n<\/ol><p class=\"no-margin\">Save the changes:<\/p><p class=\"no-margin\">\n<\/p><div class=\"intercom-container intercom-align-center\"><img decoding=\"async\" src=\"\/support\/wp-content\/uploads\/sites\/55\/2023\/11\/c8bb9a5c-e27a-408d-8bf5-a56435806867.jpg\" alt=\"Creating a new file in the file manager\" width=\"500\"><\/div><p class=\"no-margin\">\n<\/p><h2 id=\"h_12d4562151\">Step 3 &mdash; Check for the Necessary PHP Extensions<\/h2><p class=\"no-margin\">Make sure the following extensions are enabled in your website&rsquo;s <b><a href=\"\/support\/4667515-how-to-manage-php-extensions-and-options\" target=\"_blank\" class=\"intercom-content-link\">PHP configuration settings<\/a><\/b>:<\/p><ul>\n<li>\n<p class=\"no-margin\"><code>odbc<\/code><\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><code>pdo_odbc<\/code><\/p>\n<\/li>\n<\/ul><p class=\"no-margin\">\n<\/p><h2 id=\"h_9af945e32e\">Step 4 &mdash; Test the Connection<\/h2><p class=\"no-margin\">Finally, test the connection by using the following line of code:<\/p><pre><code>$dbh = new PDO(\"odbc:mssql_odbc\", \"%DB_USER%\", \"%DB_PASS%\");<\/code><\/pre><p class=\"no-margin\">If everything is set up correctly, the connection will be successful.<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"h_64cf034cd6\">What to Do if You&rsquo;re Asked to Install the ODBC Driver<\/h2><p class=\"no-margin\">If you get the following error:<\/p><pre><code>This extension requires the Microsoft ODBC Driver for SQL Server. <br>Access the following URL to download the ODBC Driver for SQL Server for x64: https:\/\/go.microsoft.com\/fwlink\/?LinkId=163712 <\/code><\/pre><p class=\"no-margin\">It means that your script is not using the <code>PDO<\/code> function<b>. <\/b><\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">At the moment, it&rsquo;s only possible to make connections to SQL servers using the <code>PDO<\/code> function for PHP. Other extensions, such as <code>sqlsrv<\/code> and similar will fail as they do not use <code>.odbc.ini<\/code> file configurations.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Connecting to the Microsoft SQL Server<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[274],"tags":[],"class_list":["post-606","post","type-post","status-publish","format-standard","hentry","category-website-development"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/8583784-how-to-connect-to-the-microsoft-sql-server-odbc-at-hostinger\/","default":1},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/support\/8583784-como-conectarse-a-microsoft-sql-server-odbc-en-hostinger\/","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/br\/support\/8583784-como-se-conectar-ao-servidor-sql-da-microsoft-no-hostinger\/","default":0}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/606","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=606"}],"version-history":[{"count":1,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/606\/revisions"}],"predecessor-version":[{"id":2762,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/606\/revisions\/2762"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}