diff --git a/.gitignore b/.gitignore index b883f1f..ca2aa22 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.exe +.vagrant/ +.DS_Store diff --git a/README.md b/README.md index 61057cb..5ba029b 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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: - host: 192.168.50.4 + host: 192.168.50.4 # Should match the private_network in Vagrantfile username: sa password: '#SAPassword!' ``` @@ -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 diff --git a/Vagrantfile b/Vagrantfile index 55eef9e..6dd796e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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 diff --git a/scripts/configure-sql-port.ps1 b/scripts/configure-sql-port.ps1 old mode 100644 new mode 100755 index f9159a0..a02e37c --- a/scripts/configure-sql-port.ps1 +++ b/scripts/configure-sql-port.ps1 @@ -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() diff --git a/scripts/enable-rdp.ps1 b/scripts/enable-rdp.ps1 old mode 100644 new mode 100755 diff --git a/scripts/install-dot-net.ps1 b/scripts/install-dot-net.ps1 old mode 100644 new mode 100755 diff --git a/scripts/install-sql-server.cmd b/scripts/install-sql-server.cmd old mode 100644 new mode 100755 index a0e50bc..7b37726 --- a/scripts/install-sql-server.cmd +++ b/scripts/install-sql-server.cmd @@ -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!