云网牛站
所在位置:首页 > Linux云服务器 > 在Ubuntu 18.04系统上安装Microsoft SQL Server的步骤

在Ubuntu 18.04系统上安装Microsoft SQL Server的步骤

2019-01-18 11:22:35作者:唯汤稿源:云网牛站

本文介绍在Ubuntu 18.04 Bionic Beaver系统上安装Microsoft SQL Server的步骤,最低系统要求:最小内存为1GB,CPU处理器最低速度为1.4 GHz,建议>=2GHz,同时SQL Server至少需要6GB的可用硬盘空间。

 

步骤1:更新Ubuntu 18.04系统

在增加软件新包时建议更新Ubuntu 18.04系统,只需要运行以下命令:

sudo apt-get update

sudo apt-get upgrade

sudo reboot

注:建议在更新系统后运行sudo reboot命令重新启动系统。

同时提一下SQL Server PHP 5.3.0驱动,支持Ubuntu 18.04系统,请参考:https://ywnz.com/linuxrj/2374.html

 

步骤2:导入公用存储库GPG密钥

添加系统的GPG密钥以信任Microsoft SQL Server apt存储库软件包:

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

 

步骤3:添加Microsoft SQL Server Ubuntu存储库

将SQL Server apt存储库添加到Ubuntu 18.04系统中:

echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/prod xenial main" | sudo tee /etc/apt/sources.list.d/mssql.list

注意:虽然上面地址中是16.04,但也可以用到Ubuntu 18.04系统中。

 

步骤4:更新包列表并安装mssql-server包

现在运行以下命令来安装SQL Server:

sudo apt-get update

sudo apt install libcurl3

sudo apt-get install -y mssql-server

返回的输出信息如下:

Reading package lists... 0%

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following packages were automatically installed and are no longer required:

grub-pc-bin libpython-all-dev python-all python-all-dev python-asn1crypto python-cffi-backend python-crypto python-cryptography python-dbus

python-enum34 python-gi python-idna python-ipaddress python-keyring python-keyrings.alt python-pkg-resources python-secretstorage

python-setuptools python-six python-wheel python-xdg

Use 'apt autoremove' to remove them.

The following NEW packages will be installed:

mssql-server

0 upgraded, 1 newly installed, 0 to remove and 15 not upgraded.

Need to get 176 MB of archives.

After this operation, 928 MB of additional disk space will be used.

Get:1 https://packages.microsoft.com/ubuntu/16.04/mssql-server-2017 xenial/main amd64 mssql-server amd64 14.0.3030.27-1 [176 MB]

Fetched 176 MB in 5s (36.3 MB/s)       

Preconfiguring packages ...

Selecting previously unselected package mssql-server.

(Reading database ... 117280 files and directories currently installed.)

Preparing to unpack .../mssql-server_14.0.3030.27-1_amd64.deb ...

Unpacking mssql-server (14.0.3030.27-1) ...

Processing triggers for libc-bin (2.27-3ubuntu1) ...

Setting up mssql-server (14.0.3030.27-1) ...

Please run 'sudo /opt/mssql/bin/mssql-conf setup'

to complete the setup of Microsoft SQL Server

SQL Server needs to be restarted in order to apply this setting. Please run

'systemctl restart mssql-server.service'.

Processing triggers for man-db (2.8.3-2) ...

Processing triggers for libc-bin (2.27-3ubuntu1) ...

注意:如果遇到错误“mssql-server : Depends: openssl (<= 1.1.0) but 1.1.0g-2ubuntu4.1 is to be installed”,请降级系统上安装的openssl版本并重新安装Microsoft SQL Server:

$ wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_1.0.2g-1ubuntu4_amd64.deb

$ sudo dpkg -i openssl_1.0.2g-1ubuntu4_amd64.deb

$ apt-get -y install mssql-server

安装完成后,通过运行初始设置/opt/mssql/bin/mssql-conf继续设置root用户密码:

$ sudo /opt/mssql/bin/mssql-conf setup

Choose an edition of SQL Server:

1)评估(免费,无生产使用权,180天限制)

2)开发者(免费,无生产使用权)

3)快递(免费)

4)Web(PAID)

5)标准(PAID)

6)企业(PAID)

7)企业核心(PAID)

8)我通过零售渠道购买了许可证,并有一个产品密钥可以进入。

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

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

Enter the SQL Server system administrator password: 

Confirm the SQL Server system administrator password: 

The passwords do not match. Please try again.

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.

将/opt/mssql-tools/bin/添加到bash shell中的PATH环境变量中,要使用bash shell访问sqlcmd/bcp以进行登录会话,请使用以下命令修改~/.bash_profile文件中的PATH:

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile

要使用bash shell访问sqlcmd/bcp以进行交互/非登录会话,请使用以下命令修改~/.bashrc文件中的PATH:

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc

source ~/.bashrc

 

步骤5:安装Microsoft SQL Server工具和unixODBC插件

运行命令:

sudo apt-get update 

sudo apt-get install mssql-tools unixodbc-dev

# sqlcmd -S localhost -U SA 

Password: 

1> create database testDB;

获取列表数据库:

在Ubuntu 18.04系统上安装Microsoft SQL Server的步骤

 

结语

在Ubuntu 18.04系统上安装Microsoft SQL Server的详细步骤就是以上5步了,其中步骤5看个人情况来安装。

 

相关主题

Ubuntu下部署SQL Server 2017(安装及使用方法,卸载方法)

精选文章
热门文章