- PHP 5.4 on Linux: How to connect with MS SQL Server 2008?
- How to install Visual Studio 2008 and MS SQL Server 2008 in Ubuntu?
- 6 Answers 6
- Sql server 2008 on linux
- Contents
- Prerequisite
- Configuration
- Setup
- Tests
- Troubleshooting
- tenbulls.co.uk
- tenbulls.co.uk – attaining enlightenment with the Microsoft Data and Cloud Platforms with a sprinkling of Open Source and supporting technologies!
- How to run SQL Server on Linux
PHP 5.4 on Linux: How to connect with MS SQL Server 2008?
I have a Linux server Debian 6, with Apache 2.2 and PHP 5.4 installed. I need to connect my application with a MS SQL Server 2008. My application is using Zend Framework 1.11 and charset UTF-8 (I’ll have users from all places in the world and they will put data in their own language). FRIST, I tried to use Microsoft SQL Server ODBC driver for Linux. It says is only for Red Hat, but I follow these instructions to install: http://www.codesynthesis.com/~boris/blog/2011/12/02/microsoft-sql-server-odbc-driver-linux/ I could connect and make some selects on it, but I couldn’t insert data on it. I got a problem on binding parameters on pdo statements. Insert data like the following didn’t work:
$stmt = $conn->prepare("insert into mar_regions (name) values (:name)"); $resp = $stmt->execute(array(':name' => $param));
$stmt = $conn->prepare("insert into mar_regions (name) values ('".$param."')"); $resp = $stmt->execute();
So I gave up from this driver, because my application no ZF 1.11 will not work if this. SECOND, I try to use PDO Driver for FreeTDS. This one works ok and I could use on my ZF 1.11 application. But then, I got one more problem: charsets. I configure my freeTDS.conf to use UTF-8, change my tables to use NVARCHAR insted of VARCHAR and could insert utf-8 data like this:
$stmt = $dbh->prepare("insert into mar_teste (name) values (N'ンから初・配信 € зеленый банан ÀÀÀÀáááááá')"); $resp = $stmt->execute();
But, on my ZF 1.11, I can’t pass this ‘N’ attribute on querys! So my application still didn’t work. As you can see I tried everything. So my question is: How to connect from linux, using ZF 1.11 charset UTF-8, on MS SQL Server 2008?
How to install Visual Studio 2008 and MS SQL Server 2008 in Ubuntu?
I would like to install Visual Studio 2008 and MS SQL Server 2008 on Ubuntu OS which I have in my PC.
Installing Visual Studio on wine is a benefit if you are developing projects say in mono, and want to develop cross-platform code that works well, and verify that it does and are like me, who doesn’t have a seperate machine to do it on and hate how slow VM runs, at this time, Wine is doing pretty good for Ubuntu i386 (stick to LTS) but NOT x64, ive found x64 stuff is crap still for the most part, if you use x64 make SURE that you install wine:i386 and not just «wine» which is of course going to default to x64 if you dont specify it explicitly.
6 Answers 6
Wine is great, but using it for either Visual Studio or MS SQL Server is probably pushing it. Both are behemoths that tend (especially VS) to use the latest MS APIs. More to the point, both VS and MSSQL are listed as Garbage in Wine’s db, meaning compatibility is very poor.
I would recommend you take a serious look at the available tools on GNU/Linux, such as MonoDevelop, Mono, Eclipse, MySQL, etc. You can use cross-platform build technologies, such as nant to build the same apps on both platforms.
If that isn’t an option, then you will have to resort to virtualization, as noted by sean.
Vicheanak, it’s really poor Microsoft. Most of what people think of as «Linux» apps (Eclipse, GIMP, gcc, Apache, MySQL, and more) are actually cross-platform, while MS shows little interest in reciprocating.
This answer might help you. Visual Studio and SQL Server are for Windows OS variants. You’ll need some sort of VM to run on Ubuntu.
If you have some sort of Windows OS disks available to you (XP / Vista / 2008), then you could consider installing Windows under VirtualBox, and installing your software inside that VM. That used to work really well for me when I was still on Ubuntu.
I found virtualbox very useful to get up and running quickly to have a Win VM in Ubuntu, without having to spend too much time configuring the VM host (as opposed to vmware).
I’ve been developing using Visual Studio in Ubuntu since version 10.04, and there is a solution, although I would recommend that you run the 64 bit version of Ubuntu and have at least 4Gb of ram available.
Install the latest version of VirtualBox (download from the website, rather than using the ubuntu repository), and install Windows as a virtual machine. You need to allocate a virtual disk and then, when the virtual machine starts for the first time, either install Windows from a CD/DVD, or select a CD image to use within VirtualBox.
You will also see, with the later versions of VirtualBox, something called «seamless mode». This essential hides the virtual machine, so that instead of running in a window, it will integrate with the Ubuntu desktop. That way, you can run Visual Studio in what looks to be native to Ubuntu.
I have tried both VMWare Player and VirtualBox and found VirtualBox to be better for my setup. Although VMWare Player has something called VMWare tools, which provides an API layer to better translate Windows calls to your video card, this can be temperamental if you’re using an ATI card (speaking from experience with a Mobility Radeon HD 4600). Nvidia provide much better driver support in Linux than ATI do.
Sql server 2008 on linux
Please note that this blog has been moved.
Now it has its own domain: mynixworld.info 🙂
If you want to read the latest version of this article (recommended) please click here and I open the page for you.
I’ve read hundreds of posts/articles that simply claim that MS-SQL Server does not run/work on Linux. Let me tell you this: that’s hogwash!
I have successfully installed MSDE 2000 (32-bit) on a Linux i686 architecture, more specifically on a Gentoo 32-bit machine where I have the WineHQ API framework, which allows applications designed for MS Windows to run on a POSIX-compliant OS.
Contents
Prerequisite
- POSIX-like 32-bit operating system (eg. Linux with Gentoo distro)
- WineHQ library for your Linux flavor
- winetricks helper script
- MSDE 2000 installation package (copy it at /tmp/MSDE2000A.exe)
Configuration
- run winescript
- click on “Select the default wineprefix” then OK
- click on “Run winecfg” then OK
- on Windows Version drop-down select Windows XP (or later version; I have tested Windows XP so at least I know that it works); Apply+OK
- check dotnet20 (I’m not really sure that it is absolutely necessary), mdac27/mdac28 then press OK; after installing these packages close the winetricks application
Setup
wine /tmp/MSDE2000A.exe # this will unpack the MSDE to ~/.wine/drive_c:/MSDERelA/ wine ~/.wine/drive_c/MSDERelA/setup.exe SAPWD="" DISABLENETWORKPROTOCOLS=0 SECURITYMODE=SQL
cp ~/.wine/drive_c/users/eugen/Temp/SqlSetup/Temp/*.* ~/.wine/drive_c/windows/system32/
The above statement copies the remaining setup’ DLL into \windows\system32 folder. After the setup.exe returns (with whatever output messages you may find on your terminal) it would be a good idea to wait few minutes (because it’s a chance that it still copies/starting/doing something while you think you are done). Then, just run the following command:
to make sure that there is a sqlservr.exe process running out there (it may appear as , but don’t worry about that).
Normally the MSSQLSERVER service should be started automatically (by setup, right after the installation finishes). You can check this in at least three ways:
- in your terminal run the command “wine net start MSSQLSERVER”; it should return an output like this:
user@gentoo ~ $ wine net start MSSQLSERVER The MSSQLSERVER service is starting. Service already running. user@gentoo ~ $
- in your terminal run the command “ps aux|grep -i sqlservr.exe”; if MSSQLSERVER is running then the command above should show the corresponding process
- in your terminal run the command
wine ~/.wine/drive_c/Program\ Files/Microsoft\ SQL\ Server/80/Tools/Binn/sqlmangr.exe
it will start an M$ application that allows you to control the MSSQLSERVER services.
If it seems that it’s not installed properly then it is worthing reading also this post.
Tests
To check the stability and performance of MS-SQL SERVER 2000 Desktop Engine (MSDE) under Linux, I’ve done few tests.
Test 1: migrate a SQL2008 database (from a Windows Server) to the SQL 2000 (MSDE) instance that runs on top of Linux:
- I have a SQL2008 database (1GB data) with the following objects:
- tables: 1043
- primary keys: 1002
- indexes: 95
- defaults: 19569
- triggers: 3819
I exported this database from SQL 2008 to SQL 2000 (MSDE) instance. It exported successfully!
I created the script for all triggers, stored procedures, functions then I run the script against the SQL 2000 (MSDE) instance on Linux. It ran successfully!
The database is (in fact) the server component of a client-server ERP package.
I have also a client application (the client component of the mentioned ERP package) that was built to run on Windows but thanks to WineHQ it runs also on Linux.
I have also installed the MDAC 2.8 on this Linux machine so that the client application connects the server component (the SQL database) by using the ADO components.
I have run the client application against the new SQL Server under Linux, so the entire solution (designed for Microsoft Windows) runs now on top of Linux. It works just perfectly!
Note: I haven’t found a way to determine SQL Server to use as many CPU as Linux provides. Maybe it’s something between SQL Server and WineHQ, I don’t know. So for the time being my SQL Sever seems to use only 1 CPU:
Screen capture of sqlservr.exe process
Also I’ve found out that the process name will appear as “sqlservr.exe ”. A defunct process means that it’s finished but still depends on its parent which is still alive. Well, I don’t know about that, SQL Server looks pretty alive to me :o)
Troubleshooting
I have found out that sqlservr.exe (that seems for a reason) will not respond if you don’t have a live connection to it that keeps him alive.
For instance, you may run the “SQL Server Service Manager” tool by running the following command:
wine "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqlmangr.exe"
SQL Server Service Manager
By using this application you can start/stop the SQL Server service.
Also I found out that we can use the osql tool to stay connected on the SQL Server and to keep it alive:
This will give you a SQL console where you can send your queries (in batch-mode, by terminating the batch with a GO on the last line):
1> select top 5 id,xtype,crdate from sysobjects 2> go id xtype crdate ----------- ----- ----------------------- 1 S 2002-12-17 14:36:14.450 2 S 2002-12-17 14:36:14.450 3 S 2002-12-17 14:36:14.450 4 S 2002-12-17 14:36:14.450 6 S 2002-12-17 14:36:14.450 (5 rows affected)
I have also found out that when querying the database from SSMS , if I query a table that has image/blob columns and if I include them in the query and if their values are not empty, then the connection between the SSMS and SQL Server is forcibly closed:
Msg 10054, Level 20, State 0, Line 0 A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)
It appears to work with no problem from osql utility but from a Windows station where I have SSMS…well, you may encounter this unfortunate situation.
tenbulls.co.uk
tenbulls.co.uk – attaining enlightenment with the Microsoft Data and Cloud Platforms with a sprinkling of Open Source and supporting technologies!
How to run SQL Server on Linux
UPDATE 2011-04-10: PLEASE NOTE THIS WAS AN APRILS FOOL JOKE 🙂
Well I have finally cracked it, after years of trying (and a little help from the R2 release) to get SQL Server to install and run happily on the Linux Platform. I could hardly believe it when it all came together, but I’m very pleased that it has. What is even more exciting is that the performance of the SQL Engine is going through the roof.
I am not entirely sure why this is, but I am assuming it is partly related to the capabilities of the EXT4 filesystem and the latest Linux Kernel improvements.
- Install WINE
- Install the .NET 3.5 framework into WINE. This is very important, otherwise the SQL Server 2008R2 installer will fail.
- Change a couple of WINE settings to allow for 64bit M.U.G extensions.
- Install the Application Release 1 for Linux Free Object Orientated Libraries by sudo apt-get install aP-R1l\ f-0Ol
- Ensure that you run setup.exe from SQL Server R2 Enterprise Edition – please note that SQL Server 2008 Release 1.5 will not work , and I additionally had problems with the Standard Edition of R2 (but not entirely sure if there is a restriction here with SQL Standard Edition Licensing on Linux).
SQL running happily in WINE on Linux Mint 10 (x64)
I think that the EXT4 filesystem is key to the success of your installation, since when I attempted this deployment using the EXT2 and EXT3 filesystems, SQL Server appeared to have issues installing.
I hope to provide more instructions and performance feedback to you all over the coming months. Enjoy!
- tables: 1043