Ubuntu: Install MSSQL
Revision as of 05:16, 18 January 2018 by Onnowpurbo (talk | contribs)
Sumber: https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu
Instalasi MSSQL di Ubuntu 16.04 Server.
Peralatan
- Ubuntu 16.04 Server
- 2G RAM
Import Repo dan Instalasi
sudo su wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)" apt update apt install -y mssql-server
Setup
sudo /opt/mssql/bin/mssql-conf setup
Isi dengan
Enter your edition(1-8): 2 Do you accept the license terms? [Yes/No]:Yes Enter the SQL Server system administrator password: Confirm the SQL Server system administrator password:
Cek Status
systemctl status mssql-server
Akan keluar
● mssql-server.service - Microsoft SQL Server Database Engine Loaded: loaded (/lib/systemd/system/mssql-server.service; enabled; vendor pre Active: active (running) since Thu 2018-01-18 05:03:29 WIB; 34s ago Docs: https://docs.microsoft.com/en-us/sql/linux Main PID: 2964 (sqlservr) CGroup: /system.slice/mssql-server.service ├─2964 /opt/mssql/bin/sqlservr └─2984 /opt/mssql/bin/sqlservr Jan 18 05:03:33 ubuntu sqlservr[2964]: [84B blob data] Jan 18 05:03:33 ubuntu sqlservr[2964]: [61B blob data] Jan 18 05:03:33 ubuntu sqlservr[2964]: [122B blob data] Jan 18 05:03:33 ubuntu sqlservr[2964]: [145B blob data] Jan 18 05:03:34 ubuntu sqlservr[2964]: [66B blob data] Jan 18 05:03:34 ubuntu sqlservr[2964]: [75B blob data] Jan 18 05:03:34 ubuntu sqlservr[2964]: [96B blob data] Jan 18 05:03:34 ubuntu sqlservr[2964]: [100B blob data] Jan 18 05:03:34 ubuntu sqlservr[2964]: [71B blob data] Jan 18 05:03:34 ubuntu sqlservr[2964]: [124B blob data]
MSSQL bekerja pada TCP port 1433
Install sqlcmd dan bcp
sudo su wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/prod.list)" apt update apt install -y mssql-tools unixodbc-dev
Jawaban Pertanyaan tentang License
Yes Yes
Perbaiki Path sqlcmd
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
sqlcmd
Connect
sqlcmd -S localhost -U SA -P '<YourPassword>'
Kalau berhasil akan keluar sqlcmd prompt
1>
Contoh
CREATE DATABASE TestDB SELECT Name from sys.Databases GO
USE TestDB CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT) INSERT INTO Inventory VALUES (1, 'banana', 150); INSERT INTO Inventory VALUES (2, 'orange', 154); GO
SELECT * FROM Inventory WHERE quantity > 152; GO
QUIT