先抛一个问题
代码语言:javascript复制[root@localhost AccountInspector]# bcp INSPECTOR_LOG.dbo.Table_NewVersionAvgDelay out t001.txt -c -U sa -P hundsun@1 -S 192.168.11.11
bash: bcp: 未找到命令...
Linux下不支持pcb,需要安装相应的工具包,安装教程如下 我的系统是CentOs7,按照Red Hat版本进行安装 1.进入超级用户模式
代码语言:javascript复制sudo su
2.下载配置文件
代码语言:javascript复制curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
3.退出超级用户模式
代码语言:javascript复制Exit
4.如果之前安装过mssql-tools ,要将那些老版本的unixODBC卸载掉
代码语言:javascript复制sudo yum update
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel
5.安装最新的unixODBC开发包
代码语言:javascript复制sudo yum update
sudo yum install mssql-tools unixODBC-devel
6.配置环境变量
代码语言:javascript复制echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
7.为了能够在不登录会话或者是交互模式可以执行sqlcmd/bcp,需要在~/.bashrc文件中修改路径
代码语言:javascript复制echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
再次执行指令发现可以使用pcb了
代码语言:javascript复制[root@localhost ~]# bcp INSPECTOR_LOG.dbo.Table_NewVersionAvgDelay out t001.txt -c -U sa -P hundsun@1 -S 192.168.11.11
Starting copy...
1000 rows successfully bulk-copied to host-file. Total received: 1000
1000 rows successfully bulk-copied to host-file. Total received: 2000
1000 rows successfully bulk-copied to host-file. Total received: 3000
1000 rows successfully bulk-copied to host-file. Total received: 4000
1000 rows successfully bulk-copied to host-file. Total received: 5000
1000 rows successfully bulk-copied to host-file. Total received: 6000
1000 rows successfully bulk-copied to host-file. Total received: 7000
1000 rows successfully bulk-copied to host-file. Total received: 8000
1000 rows successfully bulk-copied to host-file. Total received: 9000
9703 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 407 Average : (23840.3 rows per sec.)