I want to run SQLServer on my Mac but I can't do it natively. How can I host a SQLServer with VirtualBox and connect to it from my MacBook for local development?
testdatabase
) 8.1. Create a new Login: right click on Security > New > Login...
Be sure to select the SQL Server authentication
option.
8.2. In the Server Roles
tab, select the sysadmin
option:
8.3. In the User Mapping
tab, map the login to the database, and check all assign the role memberships:
Security
tab, and switch the Server Authentication mode
to SQL Server and Windows Authentication mode
:SQL Server Browser
. Open its properties and change the Startup type
to automatic:11.1. Open the Sql Server Configuration Manager program. Navigate to the Protocols
under the SQL Server Network Configuration
and Enable the TCP/IP
option:
11.2. Open the TCP/IP
properties switch to the IP Addresses tab
. Make a note of the IP Address
field under IP2
(you will need this later):
11.3. Set the TCP Port
under IPALL
to 1433
:
Configure the Firewall on the Windows VirtualBox to allow 1433 to be unblocked (I just disabled the whole firewall, probably not the best option.) edit: another user has kindly added the steps for adding a firewall rule to the end of this post.
In your Macbook's VirtualBox app, open the settings for the Windows VM and go to the Network
tab. Set the Attached to
dropdown to NAT
, then click Port Forwarding
. Add a rule to forward the VM's 1433 port to your localhost's 1433 port. The Guest IP
will be the IP from Step 11.2:
You should now be able to connect to your SQLServer from your macbook with a connection string something like this:
jdbc:sqlserver://127.0.0.1;databaseName=testdatabase
Steps to open a port in the Windows firewall for TCP access