Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Rails with mssql on macOS

Start mssql in docker

docker pull microsoft/mssql-server-linux:2017-latest
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=B4n44n123' -p 1401:1433 --name sql1 -d microsoft/mssql-server-linux:2017-latest
docker ps -a

If the server doesn’t start, check docker logs sql1.

Optional: install sqlcommand to test connection

brew tap microsoft/mssql-preview https://github.com/Microsoft/homebrew-mssql-preview
brew install msodbcsql mssql-tools

Get host ip

ipconfig getifaddr en0

Test connection

sqlcmd -S 192.168.178.30,1401 -U SA -P 'B4n44n123'

freetds, create rails app, configure db

brew install freetds
rails new mssql -d sqlserver
default: &default
  adapter: sqlserver
  encoding: utf8
  username: sa
  password: B4n44n123
  host: 192.168.178.30
  port: 1401
$ rake db:create
Created database 'mssql_development'
Created database 'mssql_test'

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.