I am trying to connect to remote Microsoft SQL server 2012 service pack 2 database from my Linux machine which is having php 5.3, php-mssql support and mysql version 5.5 enabled. Meanwhile I am getting below error message even if the login details are correct.
The ms-sql database is using Persian collation which cannot be changed. Is there any possible fix for this?
[root#i]# /usr/bin/tsql -H remove-server-ip -p 1433 -U mssql-user
locale is "en_IN"
locale charset is "UTF-8"
using default charset "UTF-8"
Msg 4075 (severity 16, state 1) from RAHKARAN Line 1:
"
The USE database statement failed because the database collation
Persian_100_CI_AI is not recognized by older client drivers. Try
upgrading the client operating system or applying a service update to
the database client software, or use a different collation. See SQL
Server Books Online for more information on changing collations."
Msg 18456 (severity 14, state 1) from RAHKARAN Line 1:
"Login failed for user 'mssql-user'."
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
Error 20002 (severity 9)
Freetds version is below
tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc
MS db-lib source compatibility: yes
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
Related
I have been working for two weeks in the installation of Superset (from Airbnb) for data visualization on a virtual RHEL machine and the connection with a SQL Server database. But I still cannot connect to this database because of a problem of driver I guess. I tried many things and I would like to know if you have a solution, about a driver I need, about modifications in my configuration etc...
Someone told me about jTDS driver. Maybe I need something like this but for python. If you have any idea, here is what I already did.
1) I tried to connect to the database from Superset :
SQL Alchemy URI : mssql://user:password#fr0-iacls-190.eu.company.corp:10001/dbname
ERROR : {"error": "Connection failed!\n\n
The error message returned was:\n(pyodbc.Error) ('IM002', '[IM002] [unixODBC][DriverManager]
Data source name not found, and no default driver specidied (0) (SQLDriverConnect)')"}
2) I tried almost the same with mssql+pymssql :
SQL Alchemy URI : mssql+pymssql://user:password#fr0-iacls-190.eu.company.corp:10001/dbname
ERROR:{"error":"Connection failed!\n\n
The error message returned was:\n(pymssql.OperationalError) (18456, 'DB-Lib error message 20018,
severity 14:\\nGeneral SQL Server error: Check messages from the SQL Server\\n
DB-Lib error message 20002, severity 9:\\n Adaptive Server connection failed (fr0-iacls-190.eu.company.corp:10001)\\n')"}
3) I tried to connect to the database from my terminal on virtual RHEL machine :
# tsql -S fr0-iacls-190.eu.company.corp -U user
Password:
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
20^C
Here I have a timer that increase the number every second. I stopped the example after 20 seconds.
4) Finally I tried a python script like this one :
import pyodbc
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=fr0-iacls-190.eu.company.corp;DATABASE=dbname;UID=;PWD=password')
The empty UID is a tip used in another StackOverflow post.
# python connect.py
Traceback (most recent call last):
File "connect.py", line 2, in <module>
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=fr0-iacls-190.eu.company.corp;DATABASE=dbname;UID=;PWD=password')
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found (0) (SQLDriverConnect)")
To finish, I read about two files, odbc.ini and odbcinst.ini but I don't know if they are in the good directory (/etc). I am not working on root (~) but in in the parent directory of root (cd ~/..)...
Here are the two files if necessary :
odbc.ini
;
; odbc.ini
;
[ODBC Data Sources]
JDBC = Sybase JDBC Server
[JDBC]
Driver = /usr/local/lib/libtdsodbc.so
Description = Sybase JDBC Server
Trace = No
Servername = JDBC
Database = pubs2
UID = guest
[Default]
Driver = /usr/local/lib/libtdsodbc.so
odbcinst.ini
[PostgreSQL]
Description=ODBC for PostgreSQL
Driver=/usr/lib/psqlodbcw.so
Setup=/usr/lib/libodbcpsqlS.so
Driver64=/usr/lib64/psqlodbcw.so
Setup64=/usr/lib64/libodbcpsqlS.so
FileUsage=1
[MySQL]
Description=ODBC for MySQL
Driver=/usr/lib/libmyodbc5.so
Setup=/usr/lib/libodbcmyS.so
Driver64=/usr/lib64/libmyodbc5.so
Setup64=/usr/lib64/libodbcmyS.so
FileUsage=1
[MSSQLTest]
Driver = ODBC Driver 13 for SQL Server
Server = [http:]fr0-iacls-190.eu.company.corp[,10001]
#
# Note:
# Port is not a valid keyword in the ~/.odbc.ini file
# for the Microsoft ODBC driver on Linux
#
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.4.0
UsageCount=1
Many thanks for your time and your help.
A few things to try:
Correct the python connection string:
You have the aliased the MS SQL driver in /etc/odbcinst.ini to [ODBC Driver 13 for SQL Server] therefore in your python code you should be using that, rather than SQL Server:
import pyodbc
cnxn = pyodbc.connect('Driver={ODBC Driver 13 for SQL Server};Server=fr0-iacls-190.eu.company.corp;Port=10001;Database=dbname;UID=user;PWD=password')
replacing user and password with correct credentials.
Use isql to test a connection using odbc.ini:
Generally you use the odbcinst.ini to setup driver configuration, and then odbc.ini for database instances (referencing the drivers), thus a valid entry to your odbc.ini could be:
[friendly_database_name]
Description=A description to help you remember what this connection is for
Server=fr0-iacls-190.eu.company.corp
Port=10001
Database=dbname
UID=user
PWD=password
If you have isql installed (comes as part of the unixODBC package if not), then you can test with:
$ isql -3 -v friendly_database_name
Ensure there's not a firewall blocking you:
I'm not sure why the tsql command is failing for you, it should return the 1> prompt. Ensure that you can establish a telnet connection to the database server:
$ telnet fr0-iacls-190.eu.company.corp 10001
which should give you something like:
Trying 12.34.56.78...
Connected to fr0-iacls-190.eu.company.corp.
Escape character is '^]'
and then to ctrl + ] and type quit to exit (or do ctrl + c to cancel if the telnet test fails).
I'm facing an issue in API call due to DB connection failure. We have tried for concurrent 90 calls to fetch some details based on some code which got failed in 1 percentage due to DB connection failure. Here is the error message “SQLSTATE[01002] Adaptive Server connection failed (severity 9)” while connecting to the DB. There are so many failures happening recently in API call due to the DB connection failure.
Is there any work around or permanent fix for this issue?
Some info,
rpm -qa | grep freetds
freetds-0.91-2.el6.x86_64 freetds-devel-0.91-2.el6.x86_64
tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc
MS db-lib source compatibility: yes
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
Please give your hands to fix this issue.
I'm trying to connect to a MS SQL Server instance using tsql (to troubleshoot not being able to connect with django-pymssql).
I can connect fine to the server (running on Amazon RDS, latest SQL Server version from on there) from a VM running SQL Server management studio, but from my native Ubuntu 15.10 env I get a login failed error.
Using the following:
tsql -H <hostname> -p 1433 -U <user> -P <mypassword>
I get:
locale is "en_GB.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Msg 18456 (severity 14, state 1) from EC2AMAZ-U1TAK71 Line 1:
"Login failed for user 'sa'."
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
As I can connect in management studio with mixed mode auth using the same creds I'm suspecting this isn't the real error.
Anyone have any ideas how I can troubleshoot?
tsql -C shows:
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc/freetds
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
Thanks loads for any pointers.!
(Accidentally posted this to AskUbuntu so have moved here. Sorry).
Answering my own question. Turns out it was down to the password being too long. I experimented with it, and any password longer than 30 characters didn't work. Seems to be a known issue with freetds.
Thanks.
I´m going to develop a Symfony2 application in my Mac OSX with MAMP, but the database (a Microsoft SQL Server one) is in another computer.
I setup everything (I followed this instruction http://jesusomar.com/2011/07/22/mamp-php-and-mssql )and if I check phpinfo() I see that mssql is active, but I´m getting this error:
[PDOException]
could not find driver
any help or clue? Thanks in advance
The first step is to check if FreeTDS is installed. You can run tsql -C to get information about MSSQL libraries in your computer. You should get something like this:
Version: freetds v0.91
freetds.conf directory: /usr/local/Cellar/freetds/0.91/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 7.1
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no
If FreeTDS is not installed, you can do it with Homebrew (for example): brew install freetds.
Now you can use MssqlBundle to connect with your database.
I have setup FreeTDS to connect to SQL Server database. When I try to open TSQL in terminal on Mac (lion) I get this error:
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20017 (severity 9):
Unexpected EOF from the server
OS error 36, "Operation now in progress"
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
Does anybody have a clue what could be causing this?
I think I got it, it's the TDS configured version, I had 5.0, which caused the error
Try running tsql -C to check what version are you using, and then you can invoke tsql overriding the version with:
TDSVER=7.0 tsql -H hostname -p port -U domain\\\username -P password
and it worked!
To make this permenant I found I need to edit the freetds.conf file and set it globally in there
vim /usr/local/freetds/etc/freetds.conf
tds version = 8.0
running tsql -C still showed that the version was 5.0 but connecting now worked every time.
TDS version need to match the correct tds protocol to connect to your db server, see below -
http://www.freetds.org/userguide/choosingtdsprotocol.htm
Choosing a TDS protocol version
***DB SERVER | TDS VERSION ***
Microsoft SQL Server 6.x = 4.2
Sybase System 10 and above = 5.0
Sybase System SQL Anywhere = 5.0
Microsoft SQL Server 7.0 = 7.0
Microsoft SQL Server 2000 = 7.1
Microsoft SQL Server 2005 = 7.2
Microsoft SQL Server 2008 = 7.2
Also missing symlink on libtdsodbc.so in /usr/lib/odbc (for me)
sudo ln /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so libtdsodbc.so
should help
I was having the same problem. In my situation, the username for the Microsoft SQL Server database was in the form, DOMAIN\userid. However, when I typed it on the command line, I think it was interpreting the slash as an escape character. When I tried putting the slash the other direction, it still failed. Finally, I tried putting two slashes in the original direction and it worked. Thus the following worked for me:
tsql -S myhost -U DOMAIN\\userid
I encountered the same error. Then I did the following, and the error went away:
pip install pyodbc
Previously, I had used quotes for the DB server, username, and pwd in the TSQL command. This time, I removed the quotes.