首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BCP通过Linux 7,无法连接到Azure SQL

BCP通过Linux 7,无法连接到Azure SQL
EN

Database Administration用户
提问于 2018-07-07 11:02:45
回答 1查看 462关注 0票数 0

我为microsoft安装了sqlcmd、bcp和odbc 17。

然后,我用SQLCMD连接到Azure SQL,它运行得很好。

然后我尝试用BCP导入一些数据,结果出错了。

我用:

代码语言:javascript
复制
 bcp schema.table_name in "path to csv file" -S example.database.windows.net -U user_name -P "password" -d schema -c -t ','

SQLState = 28000, NativeError = 18456
Error = [unixODBC][Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'user_name'.
SQLState = 01S00, NativeError = 0
Warning = [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute

我的密码是%;这可能是个问题吗?

更新:

问题是,当我使用SQLCMD时,unixODBC使用{}来转义密码,并且工作正常,但是当BCP使用unixODBC密码时不会转义。

SQL

代码语言:javascript
复制
[ODBC][12517][1530961370.439037][SQLDriverConnectW.c][290]
        Entry:
            Connection = 0x1b56e20
            Window Hdl = (nil)
            Str In = [DRIVER={ODBC Driver 17 for SQL Server};SERVER={example.database.windows.net};UID={user_name};PWD={password};WSID={ADCSrv...][length = 145 (SQL_NTS)]
            Str Out = (nil)
            Str Out Max = 0
            Str Out Ptr = (nil)
            Completion = 0
        UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'

BCP

代码语言:javascript
复制
[ODBC][19984][1530962482.429621][SQLDriverConnect.c][726]
        Entry:
            Connection = 0xcb4ef0
            Window Hdl = (nil)
            Str In = [DRIVER={ODBC Driver 17 for SQL Server};server=example.database.windows.net;UID=user_name;PWD=password][length = 109 (SQL_NTS)]
            Str Out = 0x7fff5397ce70
            Str Out Max = 2048
            Str Out Ptr = (nil)
            Completion = 0
        UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'

怎么解决这个问题?我想要创建一个DNS

EN

回答 1

Database Administration用户

回答已采纳

发布于 2018-07-07 11:50:26

对于Azure SQL数据库,请在命令行中包括数据库名称:

代码语言:javascript
复制
bcp schema.table_name in "path to csv file" -S example.database.windows.net -U user_name -P "password" -d schema -c -t ',' -d YourDatabase

编辑:

如果密码包含必须转义的字符(例如';‘但不是'%'),则需要将密码字符串括在大括号中:

代码语言:javascript
复制
bcp schema.table_name in "path to csv file" -S example.database.windows.net -U user_name -P "{pass;word}" -d schema -c -t ',' -d YourDatabase
票数 1
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/211631

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档