Sql server cho linux có gì mới

Chuyển đến nội dung chính

Trình duyệt này không còn được hỗ trợ nữa.

Hãy nâng cấp lên Microsoft Edge để tận dụng các tính năng mới nhất, bản cập nhật bảo mật và hỗ trợ kỹ thuật.

What's new for SQL Server 2019 on Linux

  • Bài viết
  • 09/27/2022
  • 2 phút để đọc

Trong bài viết này

Applies to:

Sql server cho linux có gì mới
SQL Server (all supported versions) - Linux

This article describes the major features and services available for SQL Server 2019 running on Linux. For package downloads and known issues, see the Release notes.

SLES 15 supported

Starting with SQL Server 2019 CU14, SLES 15 is now supported. Check out our Quickstart on Installing SQL Server and creating a database on SUSE Linux Enterprise Server.

Ubuntu 18.04 and 20.04 supported

  • Starting with SQL Server 2019 CU3, Ubuntu 18.04 is now supported.
  • Starting with SQL Server 2019 CU10, Ubuntu 20.04 is now supported.
  • Check out our Quickstart on Installing SQL Server and creating a database on Ubuntu.

RHEL 8 supported

Starting with SQL Server 2019 CU1, RHEL 8 is now supported. Check out our Quickstart on Installing SQL Server and creating a database on Red Hat.

Updates

The updates have been made in SQL Server 2019 on Linux:

New feature or updateDetails
Replication support SQL Server Replication on Linux
Support for the Microsoft Distributed Transaction Coordinator (MSDTC) How to configure MSDTC on Linux
OpenLDAP support for third-party Active Directory providers Tutorial: Use Active Directory authentication with SQL Server on Linux
Machine Learning on Linux Configure Machine Learning on Linux
tempdb improvements By default, a new installation of SQL Server on Linux creates multiple tempdb data files based on the number of logical cores (with up to 8 data files). This does not apply to in-place minor or major version upgrades. Each tempdb file is 8 MB with an auto growth of 64 MB. This behavior is similar to the default SQL Server installation on Windows.
PolyBase on Linux Install PolyBase on Linux for non-Hadoop connectors.

PolyBase type mapping.

Change Data Capture (CDC) support Change Data Capture (CDC) is now supported on Linux for SQL Server 2019.
Microsoft Container Registry The Microsoft Container Registry now replaces Docker Hub for new official Microsoft container images, including SQL Server 2019 (15.x).
Non-root containers SQL Server 2019 (15.x) introduces the ability to create safer containers by starting the SQL Server process as a non-root user by default. See build and run SQL Server containers as a non-root user for more details.

Next steps

To install SQL Server on Linux, use one of the following tutorials:

  • Install on Red Hat Enterprise Linux
  • Install on SUSE Linux Enterprise Server
  • Install on Ubuntu
  • Run on Docker
  • Provision a SQL VM in Azure

For answers to frequently asked questions, see the SQL Server on Linux FAQ. To see other improvements introduced in SQL Server 2019, see What's New in SQL Server 2019.

Sql server cho linux có gì mới
Get help

  • Ideas for SQL: Have suggestions for improving SQL Server?
  • Microsoft Q & A (SQL Server)
  • DBA Stack Exchange (tag sql-server): Ask SQL Server questions
  • Stack Overflow (tag sql-server): Answers to SQL development questions
  • Reddit: General discussion about SQL Server
  • Microsoft SQL Server License Terms and Information
  • Support options for business users
  • Contact Microsoft
  • Additional SQL Server help and feedback

Phản hồi

Gửi và xem ý kiến phản hồi dành cho

Microsoft SQL Server là cơ sở dữ liệu rất nổi tiếng của Microsoft. Nó được sử dụng rộng rãi trong trường học, doanh nghiệp vì dễ cài đặt và dễ sử dụng. Việc cài đặt Microsoft SQL Server trên Windows là khá dễ dàng . Bạn chỉ cần tải về cài đặt SQL Server Management Studio (SSMS) là sẽ được tự động cài đặt những thứ cần thiết. Tuy nhiên, trên CentOS/Ubuntu muốn sử dụng SQL Server lại phức tạp hơn một tí. Dưới đây là các bước cài đặt MSSQL trên Centos/Ubuntu

Yêu cầu cấu hình tối thiểu:

2 Core CPU

2G Ram

Nội dung

  • Cài đặt SQL Server trên CentOS/RHEL
  • Cài đặt SQL Server trên Ubuntu
  • Cài đặt MsSql Tool
  • Kết nối và truy cập dữ liệu SQL Server

Cài đặt SQL Server trên CentOS/RHEL

Tải Microsoft SQL Server Red Hat repository

# curl https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo -o /etc/yum.repos.d/mssql-server-2019.repo

Cài đặt SQL Server

# sudo yum install -y mssql-server

Installed:
mssql-server.x86_64 0:14.0.1.246-6
Dependency Installed:
bzip2.x86_64 0:1.0.6-13.el7 gdb.x86_64 0:7.6.1-80.el7

Cấu hình SQL Server

Sau khi hoàn tất cài đặt packages, _ cần chạy script để cấu hình. Lựa chọn Edition cho SQL muốn sử dụng

Nhấp YES để chấp nhận license và password đạt yêu cầu 8 kí tự trở lên bao gồm kí tự viết hoa, viết thường, số, kí tự đặc biệt.

# sudo /opt/mssql/bin/sqlservr-setup


Microsoft(R) SQL Server(R) Setup

You can abort setup at anytime by pressing Ctrl-C. Start this program with the –help option for information about running it in unattended mode.

The license terms for this product can be downloaded from http://go.microsoft.com/fwlink/?LinkId=746388 and found
in /usr/share/doc/mssql-server/LICENSE.TXT.

Do you accept the license terms? If so, please type “YES”: YES

Please enter a password for the system administrator (SA) account:password
Please confirm the password for the system administrator (SA) account:password
Setting system administrator (SA) account password…
Do you wish to start the SQL Server service now? [y/n]: y
Do you wish to enable SQL Server to start on boot? [y/n]: y
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server-telemetry.service to /usr/lib/systemd/system/mssql-server-telemetry.service.
Setup completed successfully.

Cài đặt xong, kiểm tra nếu SQL Server service đang chạy

# systemctl status mssql-server
● mssql-server.service – Microsoft(R) SQL Server(R) Database Engine
Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2016-11-17 03:43:32 UTC; 7min ago

a. Nhập public repository GPG keys

# sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

b. Đăng ký Microsoft SQL Server Ubuntu repository

Ubuntu 20.04:
# sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"

Ubuntu 18.04
# sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"

Ubuntu 16.04:
# sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2019.list)"

c. Cài đặt SQL Server

# sudo apt-get update
# sudo apt-get install -y mssql-server

d. Cấu hình SQL Server

Cấu hình giống như hướng dẫn đối với CentOS

sudo /opt/mssql/bin/sqlservr-setup

Cài đặt xong, kiểm tra nếu SQL Server service đang chạy

systemctl status mssql-server

Cài đặt MsSql Tool

Để cài đặt, _ cần sử dụng quyền superuser # sudo su

a. Đối với CentOS/RHEL

Tải file cấu hình Microsoft Red Hat repository

# curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo

Cài đặt MsSql Tool (YES để chấp nhận license term)

# sudo yum update
# sudo yum install mssql-tools unixODBC-devel

b. Đối với Ubuntu

Nhập GPG keys repository

# curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

Đăng kí Microsoft Ubuntu repository

Ubuntu 20.04:

# curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

Ubuntu 18.04:

# curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

Ubuntu 16.04:

# curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

Cập nhật hệ thống và cài đặt MsSql Tool

# sudo apt-get update
# sudo apt-get install mssql-tools unixodbc-dev

Kết nối và truy cập dữ liệu SQL Server

a. Kết nối cơ sở dữ liệu SQL Server

Để kết nối SQL Server trên Linux, _ cần sử dụng SQL Authentication. Chúng ta cần mở port SQL Server (mặc định là port 1433 qua tcp) trên Firewall.

Nếu thiết lập tường lửa bằng Iptables:

# iptables -A INPUT -p tcp -m tcp –dport 1433 -j ACCEPT

Nếu thiết lập tường lửa bằng FirewallD:

sudo firewall-cmd –zone=public –add-port=1433/tcp –permanent
sudo firewall-cmd –reload

Kết nối SQL Server qua sqlcmd với các thông số về SQL Server name (-S), username (-U) và password (-P)

# sqlcmd -S localhost -U SA -P ‘YourPassword’

Để kết nối từ xa, chỉ định tên máy hoặc IP cho thông số -S, ví dụ

# sqlcmd -S localhost -U SA -P ‘YourPassword’

b. Truy vấn cơ sở dữ liệu SQL Server

Sau khi kết nối thành công SQL Server có thể chạy các truy vấn đề trả về thông tin hoặc tạo các cơ sở dữ liệu. Sau đây là một số ứng dụng cơ bản

Truy vấn danh sách cơ sở dữ liệu

Tạo và sử dụng cơ sở dữ liệu mới

CREATE DATABASE testdb;
GO

Sử dụng CSDL testdb vừa tạo

USE testdb;
GO

Tạo và chèn dữ liệu vào 1 bảng trong cơ sở dữ liệu mới

Tạo 1 bảng gồm 3 trường:

– Trường số thứ tự ID (key), loại dữ liệu INT
– Trường tên Name, loại dữ liệu NVARCHAR
– Trường số lượng Quantity loại dữ liệu INT
CREATE TABLE inventory (id INT, name NVARCHAR(50), quantity INT);
GO
Nhập dữ liệu, mỗi dữ liệu 1 dòng, các trường ngăn cách nhau bởi dấu ,và bảo vệ dữ liệu bằng text qualifier ”

1, Banana, số lượng 150
2, Orange, số lượng 154

INSERT INTO inventory VALUES (1, ‘banana’, 150);
INSERT INTO inventory VALUES (2, ‘orange’, 154);
GO
Truy vấn bảng dữ liệu

Tìm kiếm những bản ghi có số lượng >152. Kết quả trả về orange

SELECT * FROM inventory WHERE quantity > 152;
GO
id name quantity
———– ————————————————– ———–
2 orange 154

(1 rows affected)

Thoát phiên làm việc Sqlcmd, gõ QUIT

Chúc các bạn thành công.