在 Linux 上安装 SQLSRV 驱动程序,还是其他支持 UTF-8 的驱动程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11839368/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Install SQLSRV driver on Linux, or other UTF-8 capable driver?
提问by hsuk
SQLSRV is the only driver for PHP that is capable of storing UTF-8strings into two-byte columns (NVARCHAR
instead of VARCHAR
) which is currently maintained and supported by Microsoft for PHP 5.2.X and 5.3.X.
SQLSRV 是唯一能够将UTF-8字符串存储到两字节列(NVARCHAR
而不是VARCHAR
)的 PHP 驱动程序,Microsoft 目前为 PHP 5.2.X 和 5.3.X 维护和支持该列。
And I also got the link for downloading these drivers Linux SQLSRV driver downloadfor linux but I could not configure.
我还得到了下载这些驱动程序的链接,用于 linux 的Linux SQLSRV 驱动程序下载,但我无法配置。
If someone has got idea how to configure the sqlsrvdriver on linux or has some other alternative to retrieve the data from SQLserver in UTF-8format, please share.
如果有人知道如何在 linux 上配置sqlsrv驱动程序或有其他一些替代方法来以UTF-8格式从SQL服务器检索数据,请分享。
回答by user1161625
I Googled a bit more after I read this and I may have found the answer. On Debian:
读完这篇文章后,我在谷歌上搜索了更多,我可能已经找到了答案。在 Debian 上:
# apt-get install freetds-common freetds-bin unixodbc php5-mssql
That will install everything PHP needs for Free TDS and allows me to connect using the sqlsrv driver.
这将安装免费 TDS 所需的一切 PHP,并允许我使用 sqlsrv 驱动程序进行连接。
回答by Kirill Morozov
Other UTF-8 compatible solution dblib:
其他 UTF-8 兼容解决方案 dblib:
You install freetds and use php-mssql driver with PDO.
Change encoding in /etc/freetds.conf
Change charset and date format in /etc/locales.conf
您安装 freetds 并使用带有 PDO 的 php-mssql 驱动程序。
在 /etc/freetds.conf 中更改编码
在 /etc/locales.conf 中更改字符集和日期格式
I did it back in 2010.
我是在 2010 年做的。
回答by GardenRouteGold
Here's a wiki post from the Microsoft Community
这是来自 Microsoft 社区的 wiki 帖子
https://github.com/Microsoft/msphpsql/wiki/Install-pdo_sqlsrv-for-PHP-7.0-on-Debian
https://github.com/Microsoft/msphpsql/wiki/Install-pdo_sqlsrv-for-PHP-7.0-on-Debian
I think the easiest route would be the php-pear route
我认为最简单的路线是 php-pear 路线
# (1) Install PDO driver from pecl
apt-get install unixodbc-dev php7.0-dev php-pear
pecl install pdo_sqlsrv-4.0.5
echo -e "; priority=20\nextension=pdo_sqlsrv.so" > /etc/php/7.0/mods-available/pdo_sqlsrv.ini
phpenmod -v 7.0 pdo_sqlsrv
回答by jerry145
Please change:
请更换:
echo -e "; priority=20\nextension=pdo_sqlsrv.so" > /etc/php/7.0/mods- available/pdo_sqlsrv.ini
to:
到:
echo -e "; priority=20\nextension=pdo_sqlsrv.so" > /etc/php/7.0/mods-available/pdo_sqlsrv.ini