Difference between revisions of "Ubuntu: Install MSSQL"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) |
Onnowpurbo (talk | contribs) (→Setup) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Sumber: https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu | 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 - | 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 | |
− | + | Choose an edition of SQL Server: | |
− | + | 1) Evaluation (free, no production use rights, 180-day limit) | |
+ | 2) Developer (free, no production use rights) | ||
+ | 3) Express (free) | ||
+ | 4) Web (PAID) | ||
+ | 5) Standard (PAID) | ||
+ | 6) Enterprise (PAID) | ||
+ | 7) Enterprise Core (PAID) | ||
+ | 8) I bought a license through a retail sales channel and have a product key to enter. | ||
− | + | 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== | |
− | |||
− | |||
− | |||
− | |||
− | Install | ||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | sudo su | ||
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - | 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"' >> ~/.bash_profile | ||
Line 95: | Line 89: | ||
source ~/.bashrc | source ~/.bashrc | ||
− | + | ==sqlcmd== | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Connect | |
− | |||
sqlcmd -S localhost -U SA -P '<YourPassword>' | 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) | CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT) | ||
− | |||
− | |||
− | |||
− | |||
INSERT INTO Inventory VALUES (1, 'banana', 150); INSERT INTO Inventory VALUES (2, 'orange', 154); | INSERT INTO Inventory VALUES (1, 'banana', 150); INSERT INTO Inventory VALUES (2, 'orange', 154); | ||
− | + | GO | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
SELECT * FROM Inventory WHERE quantity > 152; | SELECT * FROM Inventory WHERE quantity > 152; | ||
− | + | GO | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
QUIT | QUIT | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Referensi== | ==Referensi== | ||
* https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu | * https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu |
Latest revision as of 10:21, 22 January 2018
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
Choose an edition of SQL Server: 1) Evaluation (free, no production use rights, 180-day limit) 2) Developer (free, no production use rights) 3) Express (free) 4) Web (PAID) 5) Standard (PAID) 6) Enterprise (PAID) 7) Enterprise Core (PAID) 8) I bought a license through a retail sales channel and have a product key to enter.
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