Last active
March 21, 2017 12:37
-
-
Save rponte/0b1e61a4597446a5d0300eb882cc345a to your computer and use it in GitHub Desktop.
Script to install MS SQL Server vNext on Linux Ubuntu 16.04 x64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Connecting to database - https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-connect-and-query-sqlcmd | |
## | |
# how to connect? | |
sqlcmd -S localhost -U SA -P 'vagrant@2017' | |
# how to select all database names? | |
SELECT Name from sys.Databases; | |
GO | |
# how to create a new database? | |
CREATE DATABASE testdb; | |
GO | |
# how to use the database? | |
USE testdb; | |
GO | |
# how to exit? | |
QUIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e # Exit script immediately on first error. | |
set -x # Print commands and their arguments as they are executed. | |
# Check if SQL Server environment is already installed | |
RUN_ONCE_FLAG=~/.mssqlserver_env_build_time | |
if [ -e "$RUN_ONCE_FLAG" ]; then | |
echo "SQL Server environment is already installed." | |
exit 0 | |
fi | |
## | |
# Sqlserver tools - https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-ubuntu | |
## | |
# 1. imports and registers public repository | |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - | |
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list | |
# 2. installs package | |
sudo apt-get update -y | |
sudo apt-get install -y mssql-server | |
# 3. configures database | |
sudo SA_PASSWORD='vagrant@2017' /opt/mssql/bin/sqlservr-setup --accept-eula --set-sa-password --enable-service | |
# 4. starts database instance | |
sudo systemctl start mssql-server | |
## | |
# Sqlserver tools - https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools#ubuntu | |
## | |
# 5. imports and registers public repository | |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - | |
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list | |
# 6. installs package | |
sudo apt-get update -y | |
# I couldnt figure out how to configure non-interactive mode yet | |
#sudo apt-get install mssql-tools -y | |
# Cleaning unneeded packages | |
sudo apt-get autoremove -y | |
sudo apt-get clean | |
# Configures prompt color | |
sed -i 's/#force_color_prompt=yes/force_color_prompt=yes/g' ~/.bashrc | |
# sets "run once" flag | |
date > $RUN_ONCE_FLAG |
Executing this script outputs this error: sudo: /opt/mssql/bin/sqlservr-setup: command not found
Any suggestions?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo ACCEPT_EULA=Y apt-get install mssql-tools -y