r - sql server 升级到 TLS 1.2 后将 R 连接到 SQL Server 时遇到问题
问题描述
我一直使用以下代码成功连接到 R 中的 sql server
dbhandle=odbcDriverConnect("Driver={SQL Server};Server=servername;Database=databasename;Trusted_Connection=Yes")
但是,sql server 升级为兼容 TLS 1.2 后出现以下错误
Warning messages:
1: In odbcDriverConnect("Driver={SQL Server};Server=MHPOPMMSS100;Database=REZNKWB01;Trusted_Connection=Yes") :
[RODBC] ERROR: state 08001, code 18, message [Microsoft][ODBC SQL Server Driver][DBNETLIB]SSL Security error
2: In odbcDriverConnect("Driver={SQL Server};Server=MHPOPMMSS100;Database=REZNKWB01;Trusted_Connection=Yes") :
[RODBC] ERROR: state 01000, code 1, message [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (SECCreateCredentials()).
3: In odbcDriverConnect("Driver={SQL Server};Server=MHPOPMMSS100;Database=REZNKWB01;Trusted_Connection=Yes") :
ODBC connection failed
我从来不需要 uid,但我尝试输入用于直接连接到 sql server 的相同用户 ID,我尝试过 trustconnection=yes 和否,我尝试在服务器之后添加端口,基本上是我在网上阅读的任何内容我努力了。
我想知道是否有我遗漏的东西或者是否有人有意见。谢谢!
解决方案
library(RODBC)
dbconnection <- odbcDriverConnect("Driver=ODBC Driver 11 for SQL Server;Server=Server_Name; Database=DB_Name;Uid=; Pwd=; trusted_connection=yes")
initdata <- sqlQuery(dbconnection,paste("select * from MyTable;"))
odbcClose(channel)
另外,请参阅下面的链接。
http://stackoverflow.com/questions/15420999/rodbc-odbcdriverconnect-connection-error
https://andersspur.wordpress.com/2013/11/26/connect-r-to-sql-server-2012-and-14/
最后,确保您的设置兼容 32 位或 64 位。在 SQL Server 中,执行以下操作:选择 @@Version
这将告诉您使用的是 32 位还是 64 位。确保您的 R Studio 与您正在运行的任何版本的 SQL Server 兼容。
Note that by holding down the Control key during the launch of RStudio you can cause the R version selection dialog to display at startup.
推荐阅读
- jquery - 获取单选框内标签的名称
- asp.net - 什么是 obj/Debug/netcoreapp2.1/Razor 文件夹?
- excel - 为什么这个循环找不到我明显存在的文件?
- swift - Kotlin 是否支持像 swift 这样的可选构造函数?
- pandas - 按 3 列和日期范围合并 2 个数据框
- python - BeautifulSoup 如何使用 for 循环并提取特定数据?
- wordpress - WordPress 通过代理后面的 Docker - cURL 错误 7,没有路由到主机
- angular - 如何在 rxjs/operator 中使用 map
- python - “没有名为‘cv2’的模块”但已安装
- java - 日志记录不适用于 Spring boot 2.1.1 和 JDK 11 升级