Microsoft SQL Serverは、Microsoftによって開発されたリレーショナルデータベース管理システムです。データベースサーバーとして、ネットワーク(インターネットを含む)上の同じコンピューターまたは別のコンピューターで実行される可能性のある他のソフトウェアアプリケーションからの要求に応じてデータを保存および取得するという主な機能を備えたソフトウェア製品です。
ここLinuxAPTでは、サーバー管理サービスの一部として、お客様が関連するMicrosoftSQLクエリを実行するのを定期的に支援しています。
これに関連して、CentOS8マシンにMicrosoftSQLServerをインストールする方法を検討します。
CentOSにMicrosoftSQLServerをインストールする手順
1.システムアップデートを実行します
まず、次のコマンドを実行して、システムが最新であることを確認することから始めましょう。
$ sudo dnf clean all
$ sudo dnf update
2.システムにMicrosoftSQLServerをインストールします
SQL Server 2019リポジトリを追加する必要があります:
$ sudo curl https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo -o /etc/yum.repos.d/mssql-server-2019.repo
$ sudo curl https://packages.microsoft.com/config/rhel/8/prod.repo -o /etc/yum.repos.d/msprod.repo
次に、次のコマンドを実行してSQLServerをインストールします。
$ sudo dnf install mssql-server
パッケージのインストールが完了したら、mssql-confセットアップを実行し、プロンプトに従ってSAパスワードを設定し、エディションを選択します。
$ /opt/mssql/bin/mssql-conf setup
usermod: no changes
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) - CPU Core utilization restricted to 20 physical/40 hyperthreaded
7) Enterprise Core (PAID) - CPU Core utilization up to Operating System Maximum
8) I bought a license through a retail sales channel and have a product key to enter.
Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=2109348&clcid=0x409
Use of PAID editions of this software requires separate licensing through a
Microsoft Volume Licensing program.
By choosing a PAID edition, you are verifying that you have the appropriate
number of licenses in place to install and run this software.
# select an edition you'd like to use
Enter your edition(1-8): 2
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=2104294&clcid=0x409
The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409
構成が完了したら、サービスが実行されていることを確認し、サービスを開始して、起動時に開始するように設定する必要があります。
$ sudo systemctl status mssql-server.service
$ sudo systemctl is-enabled mssql-server.service
3.MSSQLのファイアウォールを構成する
デフォルトのSQLServerポートはTCP1433です。ファイアウォールにFirewallDを使用している場合は、次のコマンドを使用できます。
$ sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
$ sudo firewall-cmd --reload
4.MSSQLサーバーに接続します
インストールが完了したら、次のコマンドを使用してMSSQLサーバーに接続します。
sqlcmd -H 127.0.0.1 -U sa
Password:
1>
sqlcmd with parameters for your SQL Server name (-S), the user name (-U), and the password (-P).