VS Code+.Netでアプリを作る(No.9):Microsoft.SqlServerをUbuntu20.04へインストールする

Ubuntu20.04LTSで Microsoft.SqlServerをインストールしようとした際、エラーが発生して前に進めなくなったので調査する。

$ dotnet add package Microsoft.SqlServer

info : パッケージ 'Microsoft.SqlServer' の PackageReference をプロジェクト '/home/keisuke/dotnet/ContactBook/ContactBook.csproj' に追加しています。
info : /home/keisuke/dotnet/ContactBook/ContactBook.csproj のパッケージを復元しています...
info :   GET https://api.nuget.org/v3-flatcontainer/microsoft.sqlserver/index.json
info :   NotFound https://api.nuget.org/v3-flatcontainer/microsoft.sqlserver/index.json 657 ミリ秒
error: パッケージ Microsoft.SqlServer が見つかりません。ソース nuget.org には、この ID のパッケージが存在しません。 

VS Code+.Netでアプリを作る(No.7):.Net Coreを使ってMySQL接続(インストール編)参照。

使っているのはMySQLなのにasp-condegeneratorを使うためにSqlServerをインストールする必要があるなんて。。。 ということで、Ubuntu20.04LTSにSqlServerをインストールする。
1. パブリック リポジトリの GPG キーをインポートします。
$ wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

2. SQL Server 2019 用の Microsoft SQL Server Ubuntu リポジトリを登録します。
$ sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"

3.次のコマンドを実行して SQL Server をインストールします。
$ sudo apt-get update
$ sudo apt-get install -y mssql-server
-----
+--------------------------------------------------------------+
'sudo /opt/mssql/bin/mssql-conf setup' を実行し、
Microsoft SQL Server のセットアップを完了してください
+--------------------------------------------------------------+

4. パッケージのインストールが完了したら、mssql-conf setup を実行し、プロンプトに従って SA パスワードを設定し、エディションを選択します。
$ sudo /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=2109348clcid=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.

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=2104294clcid=0x409

The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010clcid=0x409

Do you accept the license terms? [Yes/No]:Yes

Enter the SQL Server system administrator password: 
Confirm the SQL Server system administrator password: 
Configuring SQL Server...

ForceFlush is enabled for this instance. 
ForceFlush feature is enabled for log durability.
Created symlink /etc/systemd/system/multi-user.target.wants/mssql-server.service → /lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.
これでインストール完了。
再度、nugetでMicrosoft.SqlServerをprojにインストール。
$ dotnet add package Microsoft.SqlServer.SqlManagementObjects --version 160.2004021.0
......
info : Package 'Microsoft.SqlServer.SqlManagementObjects' is compatible with all the specified frameworks in project '/home/vagrant/code/dotnet/ContactBook/ContactBook.csproj'.
info : PackageReference for package 'Microsoft.SqlServer.SqlManagementObjects' version '160.2004021.0' added to file '/home/vagrant/code/dotnet/ContactBook/ContactBook.csproj'.
info : Committing restore...
info : Writing assets file to disk. Path: /home/vagrant/code/dotnet/ContactBook/obj/project.assets.json
log  : Restored /home/vagrant/code/dotnet/ContactBook/ContactBook.csproj (in 11.18 sec).
成功!
参考:

デバッグ実行
デバッグ実行を行うとブラウザが起動するので、下記URLにアクセスします。
https://localhost:5001/Contacts

コメント

このブログの人気の投稿

ソリューション構成ごとにconfigファイルを作成する

C++の古いプロジェクトのビルドでerror MIDL2311 : statements outside library block are illegal in mktyplib compatability mode

web.config debug/releaseの内容を変換構文を使って切り替える