Connect To Microsoft Sql Server From Mac
- Can't Connect To Server
- Microsoft Sql Server Tutorial
- Microsoft Sql Server Express
- Mysql
- Free Microsoft Sql Server
- Windows Connect To Server
- Connect Sql Server From Mac
- Apr 26, 2017 Start Tableau Desktop. Click Connect to Data and then select Microsoft SQL Server. In the Server box, type the server's fully qualified domain name (such as mydb.test.ourdomain.lan). Select Use Windows Authentication, enter your Active Directory user name and password, and click Connect.
- 2020-3-19 Microsoft SQL Server driver comes with Microsoft Office 2019 with your Office 365 subscription. There's nothing extra you need to purchase. Please ignore the wrong information provided by the artificial intelligence robot Waqas. You set the connection string using the iODBC data connection manager that comes with Mac OS sometimes.
- 2017-7-30 Connect to SQL Server. Now that sql-cli is installed, we can start working with SQL Server via the Terminal window on our Mac. Connect to SQL Server using the mssql command, followed by the username and password parameters. Mssql -u sa -p reallyStrongPwd123 You should see.
- Linux and macOS Installation Tutorial for the Microsoft Drivers for PHP for SQL Server.; 11 minutes to read +1; In this article. The following instructions assume a clean environment and show how to install PHP 7.x, the Microsoft ODBC driver, the Apache web server, and the Microsoft Drivers for PHP for SQL Server on Ubuntu 16.04, 18.04, and 19.10, RedHat 7 and 8, Debian 8, 9, and 10.
- The following instructions assume you already have a SQL Server database running somewhere that your Mac has network access to. Just FYI, Microsoft's instructions for installing the latest drivers are here. Install FreeTDS and unixODBC. The connection to SQL Server will be made using the unixODBC driver manager and the FreeTDS driver.
- 2019-4-17 笔者是Mac的追随者,无奈本学期数据库课要求使用Microsoft的SQL server。但是Microsoft并没有发布SQL server for Mac ,笔者使用Google搜索后,发现可以M. 博文 来自: hellopeter1的博客.
Microsoft’s recent Connect; event included a lot of interesting announcements. The one that really got my attention was SQL Server for Linux.My first question, of course: Can I run this on my Mac? Microsoft office 2011 for mac.
以下说明假定一个干净的环境,并演示如何在 Ubuntu 16.04、18.04 和 19.10、RedHat 7 和 8、Debian 8、9 和 10、Suse 12 和 15、Alpine 3.11(实验版)以及 macOS 10.13、10.14 和 10.15 上安装 PHP 7.x、Microsoft ODBC 驱动程序、Apache Web 服务器和 Microsoft Drivers for PHP for SQL Server。The following instructions assume a clean environment and show how to install PHP 7.x, the Microsoft ODBC driver, the Apache web server, and the Microsoft Drivers for PHP for SQL Server on Ubuntu 16.04, 18.04, and 19.10, RedHat 7 and 8, Debian 8, 9, and 10, Suse 12 and 15, Alpine 3.11 (experimental), and macOS 10.13, 10.14, and 10.15.这些说明建议使用 PECL 安装驱动程序,但也可以从 Microsoft Drivers for PHP for SQL Server GitHub 项目页下载预生成的二进制文件,并按照下载 Microsoft Drivers for PHP for SQL Server 中的说明安装它们。These instructions advise installing the drivers using PECL, but you can also download the prebuilt binaries from the Microsoft Drivers for PHP for SQL Server GitHub project page and install them following the instructions in Loading the Microsoft Drivers for PHP for SQL Server.有关扩展加载以及为什么不将扩展添加到 php.ini 的说明,请参阅加载驱动程序部分。For an explanation of extension loading and why we do not add the extensions to php.ini, see the section on loading the drivers.
默认情况下,这些说明安装 PHP 7.4。These instructions install PHP 7.4 by default.注意,一些受支持的 Linux 发行版默认为 PHP 7.1 或更早版本,而 SQL Server 的 PHP 驱动程序的最新版本不支持这些版本,请参阅每一节开头的说明,以安装 PHP 7.2 或 7.3。Note that some supported Linux distros default to PHP 7.1 or earlier, which is not supported for the latest version of the PHP drivers for SQL Server -- please see the notes at the beginning of each section to install PHP 7.2 or 7.3 instead.
还包括有关在 Ubuntu 上安装 PHP FastCGI 进程管理器 (PHP-FPM) 的说明。Also included are instructions for installing the PHP FastCGI Process Manager, PHP-FPM, on Ubuntu.如果使用的是 nginx Web 服务器而不是 Apache,则需要此服务。This is needed if using the nginx web server instead of Apache.
此页的内容:Contents of this page:
在 Ubuntu 16.04、18.04 和 19.10 上安装驱动程序Installing the drivers on Ubuntu 16.04, 18.04, and 19.10
备注
若要安装 PHP 7.2 或 7.3,请使用以下命令将 7.4 替换为 7.2 或 7.3。To install PHP 7.2 or 7.3, replace 7.4 with 7.2 or 7.3 in the following commands.
步骤 1。Step 1.安装 PHPInstall PHP
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 Ubuntu 的 ODBC 驱动程序。Install the ODBC driver for Ubuntu by following the instructions on the Linux installation article.
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
如果系统中只有一个 PHP 版本,则可以将最后一个步骤简化为 phpenmod sqlsrv pdo_sqlsrv
。If there is only one PHP version in the system, then the last step can be simplified to phpenmod sqlsrv pdo_sqlsrv
.
步骤 4.Step 4.安装 Apache 并配置驱动程序加载Install Apache and configure driver loading
步骤 5。Step 5.重启 Apache 并测试示例脚本Restart Apache and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
在 Ubuntu 上安装带有 PHP-FPM 的驱动程序Installing the drivers with PHP-FPM on Ubuntu
备注
若要安装 PHP 7.2 或 7.3,请使用以下命令将 7.4 替换为 7.2 或 7.3。To install PHP 7.2 or 7.3, replace 7.4 with 7.2 or 7.3 in the following commands.
步骤 1。Step 1.安装 PHPInstall PHP
通过运行验证 PHP-FPM 服务的状态Verify the status of the PHP-FPM service by running
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 Ubuntu 的 ODBC 驱动程序。Install the ODBC driver for Ubuntu by following the instructions on the Linux installation article.
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
如果系统中只有一个 PHP 版本,则可以将最后一个步骤简化为 phpenmod sqlsrv pdo_sqlsrv
。If there is only one PHP version in the system, then the last step can be simplified to phpenmod sqlsrv pdo_sqlsrv
.
验证 sqlsrv.ini
和 pdo_sqlsrv.ini
是否位于 /etc/php/7.4/fpm/conf.d/
:Verify that sqlsrv.ini
and pdo_sqlsrv.ini
are located in /etc/php/7.4/fpm/conf.d/
:
重新启动 PHP-FPM 服务:Restart the PHP-FPM service:
步骤 4.Step 4.安装并配置 nginxInstall and configure nginx
若要配置 nginx,必须编辑 /etc/nginx/sites-available/default
文件。To configure nginx, you must edit the /etc/nginx/sites-available/default
file.将 index.php
添加到指示 # Add index.php to the list if you are using PHP
的部分下的列表中:Add index.php
to the list below the section that says # Add index.php to the list if you are using PHP
:
接下来,修改以下 # pass PHP scripts to FastCGI server
部分,如下所示:Next, modify the section following # pass PHP scripts to FastCGI server
as follows:
Can't Connect To Server
步骤 5。Step 5.重启 nginx 并测试示例脚本Restart nginx and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
在 Red Hat 7 和 8 上安装驱动程序Installing the drivers on Red Hat 7 and 8
步骤 1。Step 1.安装 PHPInstall PHP
若要在 Red Hat 7 上安装 PHP,请运行以下命令:To install PHP on Red Hat 7, run the following:
备注
若要安装 PHP 7.2 或 7.3,请在以下命令中分别用 remi- php72 或 remi-php73 替换 remi-php74。To install PHP 7.2 or 7.3, replace remi-php74 with remi-php72 or remi-php73 respectively in the following commands.
若要在 Red Hat 8 上安装 PHP,请运行以下命令:To install PHP on Red Hat 8, run the following:
备注
若要安装 PHP 7.2 或7.3,请在以下命令中分别用 remi-7.2 或 remi-7.3 替换 remi-7.4。To install PHP 7.2 or 7.3, replace remi-7.4 with remi-7.2 or remi-7.3 respectively in the following commands.
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 Red Hat 7 或 8 的 ODBC 驱动程序。Install the ODBC driver for Red Hat 7 or 8 by following the instructions on the Linux installation article.
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
也可以从 Remi 存储库进行安装:You can alternatively install from the Remi repo:
步骤 4.Step 4.安装 ApacheInstall Apache
默认安装 SELinux,并在强制模式下运行。SELinux is installed by default and runs in Enforcing mode.若要允许 Apache SELinux 通过连接到数据库,请运行以下命令:To allow Apache to connect to databases through SELinux, run the following command:
步骤 5。Step 5.重启 Apache 并测试示例脚本Restart Apache and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
在 Debian 8、9 和 10 上安装驱动程序Installing the drivers on Debian 8, 9, and 10
备注
若要安装 PHP 7.2 或 7.3,请使用以下命令将 7.4 替换为 7.2 或 7.3。To install PHP 7.2 or 7.3, replace 7.4 in the following commands with 7.2 or 7.3.
步骤 1。Step 1.安装 PHPInstall PHP
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 Debian 的 ODBC 驱动程序。Install the ODBC driver for Debian by following the instructions on the Linux installation article.
可能还需要生成正确的区域设置,以使 PHP 输出在浏览器中正确显示。You may also need to generate the correct locale to get PHP output to display correctly in a browser.例如,对于 en_US UTF-8 区域设置,运行以下命令:For example, for the en_US UTF-8 locale, run the following commands:
可能需要将 /usr/sbin
添加到 $PATH
中,因为 locale-gen
可执行文件位于该位置。You may need to add /usr/sbin
to your $PATH
, as the locale-gen
executable is located there.
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
如果系统中只有一个 PHP 版本,则可以将最后一个步骤简化为 phpenmod sqlsrv pdo_sqlsrv
。If there is only one PHP version in the system, then the last step can be simplified to phpenmod sqlsrv pdo_sqlsrv
.与 locale-gen
一样,phpenmod
位于 /usr/sbin
中,因此可能需要将此目录添加到 $PATH
。As with locale-gen
, phpenmod
is located in /usr/sbin
so you may need to add this directory to your $PATH
.
步骤 4.Step 4.安装 Apache 并配置驱动程序加载Install Apache and configure driver loading
步骤 5。Step 5.重启 Apache 并测试示例脚本Restart Apache and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
在 Suse 12 和 15 上安装驱动程序Installing the drivers on Suse 12 and 15
备注
在下面的说明中,将 <SuseVersion>
替换为 Suse 版本,如果使用的是 Suse Enterprise Linux 15,它将是 SLE_15 或 SLE_15_SP1。In the following instructions, replace <SuseVersion>
with your version of Suse - if you are using Suse Enterprise Linux 15, it will be SLE_15 or SLE_15_SP1.对于 Suse 12,请使用 SLE_12_SP4(或更高版本,如果适用)。For Suse 12, use SLE_12_SP4 (or above if applicable).并不是所有版本的 PHP 都适用于所有版本的 Suse Linux,请参阅 http://download.opensuse.org/repositories/devel:/languages:/php
以查看哪些版本的 Suse 具有默认版本的 PHP 可用,或者参阅 http://download.opensuse.org/repositories/devel:/languages:/php:/
查看哪些其他版本的 PHP 可用于哪些版本的 Suse。Not all versions of PHP are available for all versions of Suse Linux - please refer to http://download.opensuse.org/repositories/devel:/languages:/php
to see which versions of Suse have the default version PHP available, or to http://download.opensuse.org/repositories/devel:/languages:/php:/
to see which other versions of PHP are available for which versions of Suse.
备注
PHP 7.4 的包不可用于 Suse 12。Packages for PHP 7.4 are not available for Suse 12.若要安装 PHP 7.2,用以下 URL 替换下面的存储库 URL:https://download.opensuse.org/repositories/devel:/languages:/php:/php72/<SuseVersion>/devel:languages:php:php72.repo
。To install PHP 7.2, replace the repository URL below with the following URL: https://download.opensuse.org/repositories/devel:/languages:/php:/php72/<SuseVersion>/devel:languages:php:php72.repo
.若要安装 PHP 7.3,用以下 URL 替换下面的存储库 URL:https://download.opensuse.org/repositories/devel:/languages:/php:/php73/<SuseVersion>/devel:languages:php:php73.repo
。To install PHP 7.3, replace the repository URL below with the following URL: https://download.opensuse.org/repositories/devel:/languages:/php:/php73/<SuseVersion>/devel:languages:php:php73.repo
.
步骤 1。Step 1.安装 PHPInstall PHP
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 Suse 的 ODBC 驱动程序。Install the ODBC driver for Suse by following the instructions on the Linux installation article.
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
备注
如果收到错误消息 Connection to 'pecl.php.net:443' failed: Unable to find the socket transport 'ssl'
,请编辑 /usr/bin/pecl 中的 pecl 脚本并删除最后一行的 -n
开关。If you get an error message saying Connection to 'pecl.php.net:443' failed: Unable to find the socket transport 'ssl'
, edit the pecl script at /usr/bin/pecl and remove the -n
switch in the last line.此开关可防止 PECL 在调用 PHP 时加载 ini 文件,从而防止加载 OpenSSL 扩展。This switch prevents PECL from loading ini files when PHP is called, which prevents the OpenSSL extension from loading.
步骤 4.Step 4.安装 Apache 并配置驱动程序加载Install Apache and configure driver loading
步骤 5。Step 5.重启 Apache 并测试示例脚本Restart Apache and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
在 Alpine 3.11 上安装驱动程序Installing the drivers on Alpine 3.11
备注
PHP 的默认版本为 7.3。The default version of PHP is 7.3.Alpine 3.11 的其他存储库中不提供 PHP 的备用版本。Alternate versions of PHP are not available from other repositories for Alpine 3.11.可以改为从源编译 PHP。You can instead compile PHP from source.
步骤 1。Step 1.安装 PHPInstall PHP
edge/community
存储库中提供了用于 Alpine 的 PHP 包。PHP packages for Alpine are found in the edge/community
repository.将以下行添加到 /etc/apt/repositories
,并将 <mirror>
替换为 Alpine 存储库镜像的 URL:Add the following line to /etc/apt/repositories
, replacing <mirror>
with the URL of an Alpine repository mirror:
然后运行:Then run:
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 Alpine 的 ODBC 驱动程序。Install the ODBC driver for Alpine by following the instructions on the Linux installation article.
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
可能需要定义区域设置:You may need to define a locale:
步骤 4.Step 4.安装 Apache 并配置驱动程序加载Install Apache and configure driver loading
步骤 5。Step 5.重启 Apache 并测试示例脚本Restart Apache and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
在 macOS High Sierra、Mojave 和 Catalina 上安装驱动程序Installing the drivers on macOS High Sierra, Mojave, and Catalina
如果还没有安装 brew,请按照以下步骤安装:If you do not already have it, install brew as follows:
备注
若要安装 PHP 7.2 或 7.3,请在以下命令中分别用 php@7.4 或 php@7.2 替换 php@7.3。To install PHP 7.2 or 7.3, replace php@7.4 with php@7.2 or php@7.3 respectively in the following commands.
步骤 1。Step 1.安装 PHPInstall PHP
PHP 现应在路径中 - 运行 php -v
以验证正在运行正确版本的 PHP。PHP should now be in your path -- run php -v
to verify that you are running the correct version of PHP.如果 PHP 不在路径中或版本不正确,则运行以下命令:If PHP is not in your path or it is not the correct version, run the following:
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 macOS 的 ODBC 驱动程序。Install the ODBC driver for macOS by following the instructions on the macOS installation article.
此外,可能需要安装 GNU make 工具:In addition, you may need to install the GNU make tools:
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
步骤 4.Step 4.安装 Apache 并配置驱动程序加载Install Apache and configure driver loading
若要查找用于 Apache 安装的 Apache 配置文件 httpd.conf
,请运行To find the Apache configuration file, httpd.conf
, for your Apache installation, run
以下命令将所需的配置追加到 httpd.conf
。The following commands append the required configuration to httpd.conf
.请确保用上一个命令返回的路径替换 /usr/local/etc/httpd/httpd.conf
:Be sure to substitute the path returned by the preceding command in place of /usr/local/etc/httpd/httpd.conf
:
步骤 5。Step 5.重启 Apache 并测试示例脚本Restart Apache and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.Free microsoft excel for mac.
测试安装Testing Your Installation
若要测试此示例脚本,请在系统的文档根目录中创建名为“testsql.php”的文件。To test this sample script, create a file called testsql.php in your system's document root.这在 Ubuntu、Debian 和 Redhat 上为 /var/www/html/
,在 SUSE 上为 /srv/www/htdocs
,在 macOS 上为 /var/www/localhost/htdocs
,在 macOS 上为 /usr/local/var/www
。This is /var/www/html/
on Ubuntu, Debian, and Redhat, /srv/www/htdocs
on SUSE, /var/www/localhost/htdocs
on Alpine, or /usr/local/var/www
on macOS.将以下脚本复制到其中,酌情替换服务器、数据库、用户名和密码。Copy the following script to it, replacing the server, database, username, and password as appropriate.在 Alpine 3.11 上,你可能还需要在 数组中将 CharacterSet$connectionOptions
指定为“UTF-8”。On Alpine 3.11, you may also need to specify the CharacterSet as 'UTF-8' in the $connectionOptions
array.
将浏览器指向 https://localhost/testsql.php (macOS 上的 https://localhost:8080/testsql.php )。Point your browser to https://localhost/testsql.php (https://localhost:8080/testsql.php on macOS).现在应能够连接到 SQL Server/Azure SQL 数据库。You should now be able to connect to your SQL Server/Azure SQL database.
另请参阅See Also
-->本文介绍如何在 Linux 上安装 Microsoft ODBC Driver for SQL Server。This article explains how to install the Microsoft ODBC Driver for SQL Server on Linux.本文还包括有关 SQL Server 的可选命令行工具(bcp
和 sqlcmd
)以及 unixODBC 开发标头的说明。It also includes instructions for the optional command-line tools for SQL Server (bcp
and sqlcmd
) and the unixODBC development headers.
本文提供了用于从 bash shell 安装 ODBC 驱动程序的命令。This article provides commands for installing the ODBC driver from the bash shell.如果要直接下载包,请参阅下载 ODBC Driver for SQL Server。If you want to download the packages directly, see Download ODBC Driver for SQL Server.
Microsoft ODBC 17Microsoft ODBC 17
以下部分介绍了如何从用于不同 Linux 分发版本的 bash shell 安装 Microsoft ODBC 驱动程序 17。The following sections explain how to install the Microsoft ODBC driver 17 from the bash shell for different Linux distributions.
重要
如果安装了暂时可用的 v17 msodbcsql
包,应先删除它,再安装 msodbcsql17
包。If you installed the v17 msodbcsql
package that was briefly available, you should remove it before installing the msodbcsql17
package.这样可避免冲突。This will avoid conflicts.msodbcsql17
包可以与 msodbcsql
v13 包并行安装。The msodbcsql17
package can be installed side by side with the msodbcsql
v13 package.
Alpine LinuxAlpine Linux
备注
必须有驱动程序版本 17.5 或更高版本,才能获得 Alpine 支持。Driver version 17.5 or higher is required for Alpine support.
DebianDebian
备注
可以将设置环境变量“ACCEPT_EULA”替换为设置 debconf 变量“msodbcsql/ACCEPT_EULA”:echo msodbcsql17 msodbcsql/ACCEPT_EULA boolean true sudo debconf-set-selections
You can substitute setting the environment variable 'ACCEPT_EULA' with setting the debconf variable 'msodbcsql/ACCEPT_EULA' instead: echo msodbcsql17 msodbcsql/ACCEPT_EULA boolean true sudo debconf-set-selections
Red Hat Enterprise Server 和 Oracle LinuxRed Hat Enterprise Server and Oracle Linux
SUSE Linux Enterprise ServerSUSE Linux Enterprise Server
UbuntuUbuntu
备注
- Ubuntu 18.04 支持需要 17.2 或更高版本的驱动程序。Driver version 17.2 or higher is required for Ubuntu 18.04 support.
- Ubuntu 18.10 支持需要 17.3 或更高版本的驱动程序。Driver version 17.3 or higher is required for Ubuntu 18.10 support.
备注
可以将设置环境变量“ACCEPT_EULA”替换为设置 debconf 变量“msodbcsql/ACCEPT_EULA”:echo msodbcsql17 msodbcsql/ACCEPT_EULA boolean true sudo debconf-set-selections
You can substitute setting the environment variable 'ACCEPT_EULA' with setting the debconf variable 'msodbcsql/ACCEPT_EULA' instead: echo msodbcsql17 msodbcsql/ACCEPT_EULA boolean true sudo debconf-set-selections
Microsoft Sql Server Tutorial
以前的版本Previous versions
以下部分提供了有关在 Linux 上安装以前版本的的 Microsoft ODBC 驱动程序的说明。The following sections provide instructions for installing previous versions of the Microsoft ODBC driver on Linux.涵盖以下驱动程序版本:The following driver versions are covered:
ODBC 13.1ODBC 13.1
以下部分介绍了如何从用于不同 Linux 分发版本的 bash shell 安装 Microsoft ODBC 驱动程序 13.1。The following sections explain how to install the Microsoft ODBC driver 13.1 from the bash shell for different Linux distributions.
Debian 8Debian 8
RedHat Enterprise Server 6RedHat Enterprise Server 6
RedHat Enterprise Server 7RedHat Enterprise Server 7
SUSE Linux Enterprise Server 11SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 12SUSE Linux Enterprise Server 12
Ubuntu 15.10Ubuntu 15.10
Ubuntu 16.04Ubuntu 16.04
Ubuntu 16.10Ubuntu 16.10
ODBC 13ODBC 13
以下部分介绍了如何从用于不同 Linux 分发版本的 bash shell 安装 Microsoft ODBC 驱动程序 13。The following sections explain how to install the Microsoft ODBC driver 13 from the bash shell for different Linux distributions.
RedHat Enterprise Server 6RedHat Enterprise Server 6
RedHat Enterprise Server 7RedHat Enterprise Server 7
Ubuntu 15.10Ubuntu 15.10
Ubuntu 16.04Ubuntu 16.04
SUSE Linux Enterprise Server 12SUSE Linux Enterprise Server 12
脱机安装Offline installation
如果希望/需要在未连接 Internet 的计算机上安装 MicrosoftMicrosoft ODBC Driver 13,则需要手动解析包依赖项。If you prefer/require the MicrosoftMicrosoft ODBC Driver 13 to be installed on a computer with no internet connection, you will need to resolve package dependencies manually.MicrosoftMicrosoft ODBC Driver 13 具有以下直接依赖项:The MicrosoftMicrosoft ODBC Driver 13 has the following direct dependencies:
- Ubuntu:libc6 (>= 2.21), libstdc++6 (>= 4.9), libkrb5-3, libcurl3, openssl, debconf (>= 0.5), unixodbc (>= 2.3.1-1)Ubuntu: libc6 (>= 2.21), libstdc++6 (>= 4.9), libkrb5-3, libcurl3, openssl, debconf (>= 0.5), unixodbc (>= 2.3.1-1)
- Red Hat:
glibc, e2fsprogs, krb5-libs, openssl, unixODBC
Red Hat:glibc, e2fsprogs, krb5-libs, openssl, unixODBC
- SUSE:
glibc, libuuid1, krb5, openssl, unixODBC
SUSE:glibc, libuuid1, krb5, openssl, unixODBC
所有这些包都具有自己的依赖项,这些依赖性可能会显示在系统上,也可能不会显示。Each of these packages in turn has their own dependencies, which may or may not be present on the system.有关此问题的常规解决方案,请参阅分发对应的包管理器文档:RedhatUbuntu 和 SUSEFor a general solution to this issue, refer to your distribution's package manager documentation: Redhat, Ubuntu, and SUSE
还有一种常见做法是,手动下载所有相关包并将其一起放置在安装计算机上,然后依次手动安装每个包,最后安装 MicrosoftMicrosoft ODBC Driver 13 包。It is also common to manually download all the dependent packages and place them together on the installation computer, then manually install each package in turn, finishing with the MicrosoftMicrosoft ODBC Driver 13 package.
Redhat Linux Enterprise Server 7Redhat Linux Enterprise Server 7
- 从
msodbcsql``.rpm
下载最新的 https://packages.microsoft.com/rhel/7/prod/ 。Download the latestmsodbcsql
.rpm
from https://packages.microsoft.com/rhel/7/prod/. - 安装依赖项和驱动程序Install dependencies and the driver.
Ubuntu 16.04Ubuntu 16.04
- 从
msodbcsql``.deb
下载最新的 https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/msodbcsql/ 。Download the latestmsodbcsql
.deb
from https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/msodbcsql/. - 安装依赖项和驱动程序Install dependencies and the driver.
SUSE Linux Enterprise Server 12SUSE Linux Enterprise Server 12
- 从
msodbcsql``.rpm
下载最新的 https://packages.microsoft.com/sles/12/prod/ 。Download the latestmsodbcsql
.rpm
from https://packages.microsoft.com/sles/12/prod/. - 安装依赖项和驱动程序。Install the dependencies and the driver.
完成包安装后,可以通过运行 ldd 并检查其输出是否缺少库来验证 MicrosoftMicrosoft ODBC Driver 13 是否可以找到其所有依赖项:After you have completed the package installation, you can verify that the MicrosoftMicrosoft ODBC Driver 13 can find all its dependencies by running ldd and inspecting its output for missing libraries:
ODBC 11ODBC 11
以下部分介绍如何在 Linux 安装 Microsoft ODBC 驱动程序 11。The following sections explain how to install the Microsoft ODBC driver 11 on Linux.安装 unixODBC 驱动程序管理器后才能开始使用该驱动程序。Before you can use the driver, install the unixODBC driver manager.有关详细信息,请参阅安装驱动程序管理器。For more information, see Installing the Driver Manager.
安装步骤Installation Steps
重要
这些说明参考了 Red Hat Linux 的安装文件 msodbcsql-11.0.2270.0.tar.gz
。These instructions refer to msodbcsql-11.0.2270.0.tar.gz
, which is installation file for Red Hat Linux.如果要安装适用于 SUSE Linux 的预览版,则文件名为 msodbcsql-11.0.2260.0.tar.gz
。If you are installing the Preview for SUSE Linux, the file name is msodbcsql-11.0.2260.0.tar.gz
.
若要安装该驱动程序:To install the driver:
请确保具有根权限。Make sure that you have root permission.
转到下载放置文件
msodbcsql-11.0.2270.0.tar.gz
的目录。Change to the directory where the download placed the filemsodbcsql-11.0.2270.0.tar.gz
.确保所拥有的 *.tar.gz 文件与你的 Linux 版本匹配。Make sure that you have the *.tar.gz file that matches your version of Linux.若要提取文件,请执行以下命令:tar xvzf msodbcsql-11.0.2270.0.tar.gz
。To extract the files, execute the following command,tar xvzf msodbcsql-11.0.2270.0.tar.gz
.转到
msodbcsql-11.0.2270.0
目录,你应在此处看到一个名为 install.sh 的文件 。Change to themsodbcsql-11.0.2270.0
directory and there you should see a file called install.sh.若要查看可用安装选项的列表,请执行以下命令: ./install.sh。To see a list of the available installation options, execute the following command: ./install.sh.
创建 odbcinst.ini的备份。Make a backup of odbcinst.ini.驱动程序安装会更新 odbcinst.ini。The driver installation updates odbcinst.ini.odbcinst.ini 包含在 unixODBC 驱动程序管理器中注册的驱动程序列表。odbcinst.ini contains the list of drivers that are registered with the unixODBC Driver Manager.若要在计算机上发现 odbcinst.ini 的位置,请执行以下命令:
odbc_config --odbcinstini
。To discover the location of odbcinst.ini on your computer, execute the following command:odbc_config --odbcinstini
.安装该驱动程序之前,请执行以下命令:
./install.sh verify
。Before you install the driver, execute the following command:./install.sh verify
../install.sh verify
告的输出会报计算机中是否具有在 Linux 上支持 ODBC 驱动程序所需的软件。The output of./install.sh verify
reports if your computer has the required software to support the ODBC driver on Linux.当你准备好在 Linux 上安装 ODBC 驱动程序时,请执行命令:
./install.sh install
。When you are ready to install the ODBC driver on Linux, execute the command:./install.sh install
.如果需要指定安装命令(bin-dir
或lib-dir
),请在“安装”选项后指定该命令 。If you need to specify an install command (bin-dir
orlib-dir
), specify the command after the install option.查看许可协议之后,键入 YES 以继续安装。After reviewing the license agreement, type YES to continue with the installation.
安装会将驱动程序放在 /opt/microsoft/msodbcsql/11.0.2270.0
中。Installation puts the driver in /opt/microsoft/msodbcsql/11.0.2270.0
.驱动程序及其支持文件必须位于 /opt/microsoft/msodbcsql/11.0.2270.0
中。The driver and its support files must be in /opt/microsoft/msodbcsql/11.0.2270.0
.
若要验证 Linux 上的 Microsoft ODBC 驱动程序是否已成功注册,请执行以下命令:odbcinst -q -d -n 'ODBC Driver 11 for SQL Server'
。To verify that the Microsoft ODBC driver on Linux was registered successfully, execute the following command: odbcinst -q -d -n 'ODBC Driver 11 for SQL Server'
.
卸载Uninstall
通过执行以下命令,可以卸载 Linux 上的 ODBC 驱动程序 11:You can uninstall the ODBC driver 11 on Linux by executing the following commands:
rm -f /usr/bin/sqlcmd
rm -f /usr/bin/bcp
rm -rf /opt/microsoft/msodbcsql
odbcinst -u -d -n 'ODBC Driver 11 for SQL Server'
驱动程序文件Driver files
Linux 上的 ODBC 驱动程序由以下组件构成:The ODBC driver on Linux consists of the following components:
组件Component | 说明Description |
---|---|
libmsodbcsql-17.X.so.X.X 或 libmsodbcsql-13.X.so.X.Xlibmsodbcsql-17.X.so.X.X or libmsodbcsql-13.X.so.X.X | 包含该驱动程序所有功能的共享对象 (so ) 动态库文件。The shared object (so ) dynamic library file that contains all of the driver's functionality.此文件安装在 ODBC Driver 17 的 /opt/microsoft/msodbcsql17/lib64/ 中和 ODBC Driver 13 的 /opt/microsoft/msodbcsql/lib64/ 中。This file is installed in /opt/microsoft/msodbcsql17/lib64/ for the Driver 17 and in /opt/microsoft/msodbcsql/lib64/ for Driver 13. |
msodbcsqlr17.rll 或 msodbcsqlr13.rll msodbcsqlr17.rll or msodbcsqlr13.rll | 驱动程序库的附带资源文件。The accompanying resource file for the driver library.此文件安装在 [driver .so directory]./share/resources/en_US/ 中This file is installed in [driver .so directory]./share/resources/en_US/ |
msodbcsql.hmsodbcsql.h | 头文件,它包含使用驱动程序所需的所有新定义。The header file that contains all of the new definitions needed to use the driver. 注意: 你无法在同一个程序中引用 msodbcsql.h 和 odbcss.h。Note: You cannot reference msodbcsql.h and odbcss.h in the same program. msodbcsql.h 安装在 ODBC Driver 17 的 /opt/microsoft/msodbcsql17/include/ 中和 ODBC Driver 13 的 /opt/microsoft/msodbcsql/include/ 中。msodbcsql.h is installed in /opt/microsoft/msodbcsql17/include/ for Driver 17 and in /opt/microsoft/msodbcsql/include/ for Driver 13. |
LICENSE.txtLICENSE.txt | 包含最终用户许可协议条款的文本文件。The text file that contains the terms of the End-User License Agreement.此文件位于 ODBC Driver 17 的 /usr/share/doc/msodbcsql17/ 中和 ODBC Driver 13 的 /usr/share/doc/msodbcsql/ 中。This file is placed in /usr/share/doc/msodbcsql17/ for Driver 17 and in /usr/share/doc/msodbcsql/ for Driver 13. |
RELEASE_NOTESRELEASE_NOTES | 包含发行说明的文本文件。The text file that contains release notes.此文件位于 ODBC Driver 17 的 /usr/share/doc/msodbcsql17/ 中和 ODBC Driver 13 的 /usr/share/doc/msodbcsql/ 中。This file is placed in /usr/share/doc/msodbcsql17/ for Driver 17 and in /usr/share/doc/msodbcsql/ for Driver 13. |
资源文件加载Resource file loading
驱动程序需要加载资源文件才能正常运行。The driver needs to load the resource file in order to function.此文件称为 msodbcsqlr17.rll
或 msodbcsqlr13.rll
,具体取决于驱动程序版本。This file is called msodbcsqlr17.rll
or msodbcsqlr13.rll
depending on the driver version..rll
文件的位置与驱动程序本身的位置(so
或 dylib
)相对,如上表中所述。The location of the .rll
file is relative to the location of the driver itself (so
or dylib
), as noted in the table above.自版本 17.1 开始,如果从相对路径加载失败,驱动程序还将尝试从默认目录加载 .rll
。As of version 17.1 the driver will also attempt to load the .rll
from the default directory if loading from the relative path fails.Linux 上的默认资源文件路径是 /opt/microsoft/msodbcsql17/share/resources/en_US/
。The default resource file path on Linux is /opt/microsoft/msodbcsql17/share/resources/en_US/
.
Microsoft Sql Server Express
故障排除Troubleshooting
Mysql
如果无法使用 ODBC 驱动程序建立与 SQL Server 的连接,请参阅解决连接问题上的“已知问题”一文。If you are unable to make a connection to SQL Server using the ODBC driver, see the known issues article on troubleshooting connection problems.
Free Microsoft Sql Server
后续步骤Next steps
Windows Connect To Server
安装驱动程序后,可以尝试 C++ ODBC 示例应用程序。After installing the driver, you can try the C++ ODBC example application.有关开发 ODBC 应用程序的详细信息,请参阅开发应用程序。For more information about developing ODBC applications, see Developing Applications.
Connect Sql Server From Mac
有关详细信息,请参阅 ODBC 驱动程序发行说明和系统要求。For more information, see the ODBC driver release notes and system requirements.