Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Update to Windows Server 2012 with SQL Server 2012 #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.exe
.vagrant/
.DS_Store
38 changes: 24 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# vagrant-mssql-express

A Windows Server 2008 R2 VM with SQL Server Express 2008 R2 SP2 powered by Vagrant.
A Windows 2012 Server with SQL Server Express 2012 powered by Vagrant.

##

This repo was forked from [here](https://github.com/fgrehm/vagrant-mssql-express). It was updated to support Sql Server Express 2012 on Windows Server 2012

## Requirements

Expand All @@ -18,38 +22,39 @@ A Windows Server 2008 R2 VM with SQL Server Express 2008 R2 SP2 powered by Vagra
* The box has been created with [packer.io](http://www.packer.io/) using the
templates made available [here](https://github.com/opentable/packer-images).

More information can be found on the [box page at Vagrant Cloud](https://vagrantcloud.com/opentable/boxes/win-2008r2-standard-amd64-nocm).
More information can be found on the [box page at Vagrant Cloud](https://atlas.hashicorp.com/opentable/boxes/win-2012r2-standard-amd64-nocm).

## Usage

```sh
git clone https://github.com/fgrehm/vagrant-mssql-express.git
git clone https://github.com/mince27/vagrant-mssql-express
cd vagrant-mssql-express
# Download SQL Server with Tools installer
wget http://download.microsoft.com/download/0/4/B/04BE03CD-EAF3-4797-9D8D-2E08E316C998/SQLEXPRWT_x64_ENU.exe
vagrant up
# Get a coffee as it will take a while for it to finish provisioning
```

Then test the connection with the SQL Server using `telnet 192.168.50.4 1433`
Get a coffee as it will take a while for it to finish provisioning. The first time it has to download the vagrant box and sql server express.


### Connecting to the SQL Server instance that runs inside the VM

* IP / Host: `192.168.50.4`
* The ip will be the private_network value defined in `Vagrantfile`
* Username: `sa`
* Password: `#SAPassword!`
* To change this modify the value in `install-sql-server.cmd`

If you are using Rails you will need the following gems
```
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter', '~> 4.2.0'
```

If you are using Rails, apart from installing [tiny_tds](https://github.com/rails-sqlserver/tiny_tds)
dependencies with `brew install freetds` / `apt-get install freetds-*` and
the [activerecord-sqlserver-adapter gem](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter),
this is what you'll have on your `database.yml`:
This is what you'll have in your `database.yml`:

```yaml
development:
adapter: sqlserver
database: <YOUR DB>
host: 192.168.50.4
host: 192.168.50.4 # Should match the private_network in Vagrantfile
username: sa
password: '#SAPassword!'
```
Expand All @@ -65,7 +70,12 @@ new databases, you can use the [`vagrant rdp` command](http://docs.vagrantup.com
and log in with the `vagrant` user and password.

For the `vagrant rdp` command to work on Ubuntu, you'll need to `apt-get install rdesktop`
first. On Macs, you will need [Microsoft Remote Desktop](https://itunes.apple.com/en/app/microsoft-remote-desktop/id715768417) from the Mac App Store.
first.

On Macs, you will need [Microsoft Remote Desktop](https://itunes.apple.com/en/app/microsoft-remote-desktop/id715768417) from the Mac App Store.

* Username: vagrant
* Password: vagrant

## More information

Expand Down
4 changes: 2 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'

if ! File.exists?('./SQLEXPRWT_x64_ENU.exe')
puts 'SQL Server installer could not be found!'
puts "Please run:\n wget http://download.microsoft.com/download/0/4/B/04BE03CD-EAF3-4797-9D8D-2E08E316C998/SQLEXPRWT_x64_ENU.exe"
puts "Please run:\n wget http://download.microsoft.com/download/8/D/D/8DD7BDBA-CEF7-4D8E-8C16-D9F69527F909/ENU/x64/SQLEXPRWT_x64_ENU.exe"
exit 1
end

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "opentable/win-2008r2-standard-amd64-nocm"
config.vm.box = "opentable/win-2012r2-standard-amd64-nocm"
config.vm.network "private_network", ip: "192.168.50.4"
config.vm.network :forwarded_port, guest: 3389, host: 3389

Expand Down
6 changes: 3 additions & 3 deletions scripts/configure-sql-port.ps1
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ echo "Configuring TCP port"

# http://technet.microsoft.com/en-us/library/dd206997(v=sql.105).aspx
# Load assemblies
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement")
Add-Type -Path 'C:\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.Smo.dll'
Add-Type -Path 'C:\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.SqlWmiManagement.dll'

# http://www.dbi-services.com/index.php/blog/entry/sql-server-2012-configuring-your-tcp-port-via-powershell
# Set the port
$smo = 'Microsoft.SqlServer.Management.Smo.'
$wmi = new-object ($smo + 'Wmi.ManagedComputer')
$uri = "ManagedComputer[@Name='WIN-2008R2-STD']/ ServerInstance[@Name='SQLEXPRESS']/ServerProtocol[@Name='Tcp']"
$uri = "ManagedComputer[@Name='" + (get-item env:computername).Value + "']/ ServerInstance[@Name='SQLEXPRESS']/ServerProtocol[@Name='Tcp']"
$Tcp = $wmi.GetSmoObject($uri)
$wmi.GetSmoObject($uri + "/IPAddress[@Name='IPAll']").IPAddressProperties[1].Value="1433"
$Tcp.alter()
Expand Down
Empty file modified scripts/enable-rdp.ps1
100644 → 100755
Empty file.
Empty file modified scripts/install-dot-net.ps1
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion scripts/install-sql-server.cmd
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

echo Installing SQL Server 2008 Express R2, it will take a while...
echo Installing SQL Server 2012 Express, it will take a while...
C:\vagrant\SQLEXPRWT_x64_ENU.exe /Q /Action=install /INDICATEPROGRESS /INSTANCENAME="SQLEXPRESS" /INSTANCEID="SQLExpress" /IAcceptSQLServerLicenseTerms /FEATURES=SQL,Tools /TCPENABLED=1 /SECURITYMODE="SQL" /SAPWD="#SAPassword!"
echo Done!

Expand Down