如何让 sqlcmd 拥有 linux 上的文件访问权限?
How make sqlcmd hold file access rights on linux?
2 天前刚刚在 Ubuntu 16.04 上安装了 sql-server。使用 sqlcmd
进行批量插入,我得到:
Msg 4860, Level 16, State 1, Line 6 Cannot bulk load. The file
"~/test_data.txt" does not exist or you don't have file access rights.
是的,文件确实存在,我使用命令 cat
.
确定了它
然后我尝试了 bcp
工具,但我得到了:
SQLState = S1000, NativeError = 0 Error = [Microsoft][ODBC Driver 13
for SQL Server]Unable to open BCP host data-file
还尝试安装 visual studio 代码并添加 mssql 扩展,但我收到了相同的 "file access rights" 警告。并且已经使用 chmod 777
试图修复它。没用。
命令批量插入 sqlcmd
:
BULK INSERT TestEmployees FROM '~/test_data.txt'
WITH(
rowterminator = ','
);
bcp
工具上的命令
bcp auth in path/auth2.tsv -S localhost -U sa -P <my password> -d Trabalho1BD -c
我认为您的问题出在批量插入命令的 '~/test_data.txt'
部分。具体来说,就是 "find a file called test_data.txt in the home directory"。但是谁的主目录?不是你的!它正在 运行 您的 SQL 服务器帐户的主目录中查找文件。尝试将其更改为完整路径(即 '/home/«username»/test_data.txt'
应该这样做。
2 天前刚刚在 Ubuntu 16.04 上安装了 sql-server。使用 sqlcmd
进行批量插入,我得到:
Msg 4860, Level 16, State 1, Line 6 Cannot bulk load. The file "~/test_data.txt" does not exist or you don't have file access rights.
是的,文件确实存在,我使用命令 cat
.
然后我尝试了 bcp
工具,但我得到了:
SQLState = S1000, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]Unable to open BCP host data-file
还尝试安装 visual studio 代码并添加 mssql 扩展,但我收到了相同的 "file access rights" 警告。并且已经使用 chmod 777
试图修复它。没用。
命令批量插入 sqlcmd
:
BULK INSERT TestEmployees FROM '~/test_data.txt'
WITH(
rowterminator = ','
);
bcp
工具上的命令
bcp auth in path/auth2.tsv -S localhost -U sa -P <my password> -d Trabalho1BD -c
我认为您的问题出在批量插入命令的 '~/test_data.txt'
部分。具体来说,就是 "find a file called test_data.txt in the home directory"。但是谁的主目录?不是你的!它正在 运行 您的 SQL 服务器帐户的主目录中查找文件。尝试将其更改为完整路径(即 '/home/«username»/test_data.txt'
应该这样做。