Apr 04, 2017 gpg -import bobpublickey.gpg Conclusion. Now we have notions on the principles to use and generate a public key. You know how GnuPG is functioning and you can use it for secure communication. GPG encryption is only useful when both parties use good security practices and are vigilant. Read Also: How to Encrypt/Decrypt File using GPG in Linux. Ubuntu 16.04: Create GPG key. This article will describe creating GPG key. When creating GPG key, the following message will be output and console will be hung. Jul 01, 2019 Once GnuPG is installed, you’ll need to generate your own GPG key pair, consisting of a private and public key. The private key is your master key. It allows you to decrypt/encrypt your files and create signatures which are signed with your private key. This brief tutorial shows students and new users how to generate and mange GPG keys on Ubuntu servers or desktops When you’re ready to get GPG working on Ubuntu, follow the steps below: Step 1: Install GnuPG. In order to use GPG encryptions, you will have to install a software that helps generate and manage your GPG encryptions and keys. Sep 18, 2019 In this guide, I’ll take you through the steps to install MS SQL server on Ubuntu 18.04 Bionic Beaver Linux. In addition, We will look at how to create a database, add users, and lastly how to do daily backups for the databases. Below are the minimum system requirements to run MS SQL on Ubuntu 18.04 / 16.04 server: Minimum memory of 1 GB.
-->In this quickstart, you install SQL Server 2017 on Ubuntu 18.04. You then connect with sqlcmd to create your first database and run queries.
In this quickstart, you install SQL Server 2019 on Ubuntu 18.04. You then connect with sqlcmd to create your first database and run queries.
Tip
This tutorial requires user input and an internet connection. If you are interested in the unattended or offline installation procedures, see Installation guidance for SQL Server on Linux.
Prerequisites
You must have an Ubuntu 16.04 or 18.04 machine with at least 2 GB of memory.
To install Ubuntu 18.04 on your own machine, go to http://releases.ubuntu.com/bionic/. You can also create Ubuntu virtual machines in Azure. See Create and Manage Linux VMs with the Azure CLI.
Note
At this time, the Windows Subsystem for Linux for Windows 10 is not supported as an installation target.
For other system requirements, see System requirements for SQL Server on Linux.
Note
Ubuntu 18.04 is supported starting with SQL Server 2017 CU20. If you want to use the instructions on this article with Ubuntu 18.04, make sure you use the correct repository path,
18.04
instead of 16.04
.If you are running SQL Server on a lower version, the configuration is possible with modifications.
You must have an Ubuntu 16.04 or 18.04 machine with at least 2 GB of memory.
To install Ubuntu 18.04 on your own machine, go to http://releases.ubuntu.com/bionic/. You can also create Ubuntu virtual machines in Azure. See Create and Manage Linux VMs with the Azure CLI.
Note
At this time, the Windows Subsystem for Linux for Windows 10 is not supported as an installation target.
For other system requirements, see System requirements for SQL Server on Linux.
Install SQL Server
Note
Gpg Key Server
The following commands for SQL Server 2017 points to the Ubuntu 18.04 repository. If you are using Ubuntu 16.04, change the path below to
/ubuntu/16.04/
instead of /ubuntu/18.04/
.To configure SQL Server on Ubuntu, run the following commands in a terminal to install the mssql-server package.
- Import the public repository GPG keys:
- Register the Microsoft SQL Server Ubuntu repository:TipIf you want to install SQL Server 2019 , you must instead register the SQL Server 2019 repository. Use the following command for SQL Server 2019 installations:
- Run the following commands to install SQL Server:
- After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password and choose your edition.TipThe following SQL Server 2017 editions are freely licensed: Evaluation, Developer, and Express.NoteMake sure to specify a strong password for the SA account (Minimum length 8 characters, including uppercase and lowercase letters, base 10 digits and/or non-alphanumeric symbols).
- Once the configuration is done, verify that the service is running:
- If you plan to connect remotely, you might also need to open the SQL Server TCP port (default 1433) on your firewall.
At this point, SQL Server is running on your Ubuntu machine and is ready to use!
Install SQL Server
Note
The following commands for SQL Server 2019 points to the Ubuntu 18.04 repository. If you are using Ubuntu 16.04, change the path below to
/ubuntu/16.04/
instead of /ubuntu/18.04/
.To configure SQL Server on Ubuntu, run the following commands in a terminal to install the mssql-server package.
Ubuntu Generate Gpg Key 2019 Free
- Import the public repository GPG keys:
- Register the Microsoft SQL Server Ubuntu repository for SQL Server 2019:
- Run the following commands to install SQL Server:
- After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password and choose your edition.NoteMake sure to specify a strong password for the SA account (Minimum length 8 characters, including uppercase and lowercase letters, base 10 digits and/or non-alphanumeric symbols).
- Once the configuration is done, verify that the service is running:
- If you plan to connect remotely, you might also need to open the SQL Server TCP port (default 1433) on your firewall.
At this point, SQL Server 2019 is running on your Ubuntu machine and is ready to use!
Install the SQL Server command-line tools
To create a database, you need to connect with a tool that can run Transact-SQL statements on the SQL Server. The following steps install the SQL Server command-line tools: sqlcmd and bcp.
Use the following steps to install the mssql-tools on Ubuntu.
Gpg Generate Public Key
- Import the public repository GPG keys.
- Register the Microsoft Ubuntu repository.
- Update the sources list and run the installation command with the unixODBC developer package. For more information, see Install the Microsoft ODBC driver for SQL Server (Linux).NoteTo update to the latest version of mssql-tools run the following commands:
- Optional: Add
/opt/mssql-tools/bin/
to your PATH environment variable in a bash shell.To make sqlcmd/bcp accessible from the bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:To make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the ~/.bashrc file with the following command:
Connect locally
The following steps use sqlcmd to locally connect to your new SQL Server instance.
- Run sqlcmd with parameters for your SQL Server name (-S), the user name (-U), and the password (-P). In this tutorial, you are connecting locally, so the server name is
localhost
. The user name isSA
and the password is the one you provided for the SA account during setup.TipYou can omit the password on the command line to be prompted to enter it.TipIf you later decide to connect remotely, specify the machine name or IP address for the -S parameter, and make sure port 1433 is open on your firewall. - If successful, you should get to a sqlcmd command prompt:
1>
. - If you get a connection failure, first attempt to diagnose the problem from the error message. Then review the connection troubleshooting recommendations.
Create and query data
The following sections walk you through using sqlcmd to create a new database, add data, and run a simple query.
Create a new database
The following steps create a new database named
TestDB
.- From the sqlcmd command prompt, paste the following Transact-SQL command to create a test database:
- On the next line, write a query to return the name of all of the databases on your server:
- The previous two commands were not executed immediately. You must type
GO
on a new line to execute the previous commands:
Tip
To learn more about writing Transact-SQL statements and queries, see Tutorial: Writing Transact-SQL Statements.
Insert data
Next create a new table,
Inventory
, and insert two new rows.- From the sqlcmd command prompt, switch context to the new
TestDB
database: - Create new table named
Inventory
: - Insert data into the new table:
- Type
GO
to execute the previous commands:
Select data
Now, run a query to return data from the
Inventory
table.- From the sqlcmd command prompt, enter a query that returns rows from the
Inventory
table where the quantity is greater than 152: - Execute the command:
Exit the sqlcmd command prompt
To end your sqlcmd session, type
QUIT
:Performance best practices
After installing SQL Server on Linux, review the best practices for configuring Linux and SQL Server to improve performance for production scenarios. For more information, see Performance best practices and configuration guidelines for SQL Server on Linux.
Cross-platform data tools
In addition to sqlcmd, you can use the following cross-platform tools to manage SQL Server:
Azure Data Studio | A cross-platform GUI database management utility. |
Visual Studio Code | A cross-platform GUI code editor that run Transact-SQL statements with the mssql extension. |
PowerShell Core | A cross-platform automation and configuration tool based on cmdlets. |
mssql-cli | A cross-platform command-line interface for running Transact-SQL commands. |
Connecting from Windows
SQL Server tools on Windows connect to SQL Server instances on Linux in the same way they would connect to any remote SQL Server instance.
If you have a Windows machine that can connect to your Linux machine, try the same steps in this topic from a Windows command-prompt running sqlcmd. Just verify that you use the target Linux machine name or IP address rather than localhost, and make sure that TCP port 1433 is open. If you have any problems connecting from Windows, see connection troubleshooting recommendations.
For other tools that run on Windows but connect to SQL Server on Linux, see:
Other deployment scenarios
For other installation scenarios, see the following resources:
Upgrade | Learn how to upgrade an existing installation of SQL Server on Linux |
Uninstall | Uninstall SQL Server on Linux |
Unattended install | Learn how to script the installation without prompts |
Offline install | Learn how to manually download the packages for offline installation |
Tip
For answers to frequently asked questions, see the SQL Server on Linux FAQ.
Next steps
-->This article describes how to configure the correct repository for SQL Server 2017 and SQL Server 2019 installations and upgrades on Linux. At the top, your current selection is Red Hat (RHEL).
This article describes how to configure the correct repository for SQL Server 2017 and SQL Server 2019 installations and upgrades on Linux. At the top, your current selection is SUSE (SLES).
This article describes how to configure the correct repository for SQL Server 2017 and SQL Server 2019 installations and upgrades on Linux. At the top, your current selection is Ubuntu.
Tip
SQL Server 2019 is now available! To try it, use this article to configure the new mssql-server-2019 repository. Then install using the instructions in the installation guide.
Repositories
When you install SQL Server on Linux, you must configure a Microsoft repository. This repository is used to acquire the database engine package, mssql-server, and related SQL Server packages. There are currently five main repositories:
Repository | Name | Description |
---|---|---|
2019 | mssql-server-2019 | SQL Server 2019 Cumulative Update (CU) repository. |
2019 GDR | mssql-server-2019-gdr | SQL Server 2019 GDR repository for critical updates only. |
2019 Preview | mssql-server-preview | SQL Server 2019 Preview and RC repository. |
2017 | mssql-server-2017 | SQL Server 2017 Cumulative Update (CU) repository. |
2017 GDR | mssql-server-2017-gdr | SQL Server 2017 GDR repository for critical updates only. |
Generate Gpg Key Windows
Cumulative Update versus GDR
It is important to note that there are two main types of repositories for each distribution:
- Cumulative Updates (CU): The Cumulative Update (CU) repository contains packages for the base SQL Server release and any bug fixes or improvements since that release. Cumulative updates are specific to a release version, such as SQL Server 2019. They are released on a regular cadence.
- GDR: The GDR repository contains packages for the base SQL Server release and only critical fixes and security updates since that release. These updates are also added to the next CU release.
Each CU and GDR release contains the full SQL Server package and all previous updates for that repository. Updating from a GDR release to a CU release is supported by changing your configured repository for SQL Server. You can also downgrade to any release within your major version (ex: 2017).
Note
You can update from a GDR release to CU release at any time by changing repositories. Updating from a CU release to a GDR release is not supported.
Configure repositories
Use the steps in the following sections to configure repositories on Red Hat Enterprise Server (RHEL).
Use the steps in the following sections to configure repositories on SUSE Linux Enterprise Server (SLES).
Use the steps in the following sections to configure repositories on Ubuntu.
Check for previously configured repositories
First verify whether you have already registered a SQL Server repository.
- View the files in the /etc/yum.repos.d directory with the following command:
- Look for a file that configures the SQL Server directory, such as mssql-server.repo.
- Print out the contents of the file.
- The name property is the configured repository. You can identify it with the table in the Repositories section of this article.
First verify whether you have already registered a SQL Server repository.
- Use zypper info to get information about any previously configured repository.
- The Repository property is the configured repository. You can identify it with the table in the Repositories section of this article.
First verify whether you have already registered a SQL Server repository.
- View the contents of the /etc/apt/sources.list file.
- Examine the package URL for mssql-server. You can identify it with the table in the Repositories section of this article.
Remove old repository
If necessary, remove the old repository with the following command.
This command assumes that the file identified in the previous section was named mssql-server.repo.
If necessary, remove the old repository. Use one of the following commands based on the type of previously configured repository.
Repository | Command to remove |
---|---|
Preview (2019) | sudo zypper removerepo 'packages-microsoft-com-mssql-server-preview' |
2019 CU | sudo zypper removerepo 'packages-microsoft-com-mssql-server-2019' |
2019 GDR | sudo zypper removerepo 'packages-microsoft-com-mssql-server-2019-gdr' |
2017 CU | sudo zypper removerepo 'packages-microsoft-com-mssql-server-2017' |
2017 GDR | sudo zypper removerepo 'packages-microsoft-com-mssql-server-2017-gdr' |
If necessary, remove the old repository. Use one of the following commands based on the type of previously configured repository.
Note
Starting with SQL Server 2019 CU3 and SQL Server 2017 CU20, Ubuntu 18.04 is supported. If you are using Ubuntu 16.04, change the path below to
/ubuntu/16.04
instead of /ubuntu/18.04
, and use the correct distribution code name.Repository | Command to remove |
---|---|
Preview (2019) | sudo add-apt-repository -r 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/mssql-server-preview xenial main' |
2019 CU | sudo add-apt-repository -r 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/18.04/mssql-server-2019 bionic main' |
2019 GDR | sudo add-apt-repository -r 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/18.04/mssql-server-2019-gdr bionic main' |
2017 CU | sudo add-apt-repository -r 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/mssql-server-2017 xenial main' |
2017 GDR | sudo add-apt-repository -r 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/mssql-server-2017-gdr xenial main' |
Configure new repository
Configure the new repository to use for SQL Server installations and upgrades. Use one of the following commands to configure the repository of your choice.
Note
The following commands for SQL Server 2019 points to the RHEL 8 repository. RHEL 8 does not come preinstalled with python2, which is required by SQL Server. For more information, see the following blog on installing python2 and configuring it as the default interpreter: https://www.redhat.com/en/blog/installing-microsoft-sql-server-red-hat-enterprise-linux-8-beta.
Starting with SQL Server 2017 CU20, RHEL 8 is supported.
If you are using RHEL 7 or RHEL 8, ensure the paths match
/rhel/7
or /rhel/8
.Repository | Version | Command |
---|---|---|
2019 CU | 2019 | sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo |
2019 GDR | 2019 | sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019-gdr.repo |
2017 CU | 2017 | sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2017.repo |
2017 GDR | 2017 | sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2017-gdr.repo |
Configure the new repository to use for SQL Server installations and upgrades. Use one of the following commands to configure the repository of your choice.
Repository | Version | Command |
---|---|---|
2019 CU | 2019 | sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-2019.repo |
2019 GDR | 2019 | sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-2019-gdr.repo |
2017 CU | 2017 | sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-2017.repo |
2017 GDR | 2017 | sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-2017-gdr.repo |
Configure the new repository to use for SQL Server installations and upgrades.
Note
Starting with SQL Server 2019 CU3 and SQL Server 2017 CU20, Ubuntu 18.04 is supported. The following commands points to the Ubuntu 18.04 repository.
If you are using Ubuntu 16.04, change the path below to
/ubuntu/16.04
instead of /ubuntu/18.04
.- Import the public repository GPG keys.
- Use one of the following commands to configure the repository of your choice.
Repository Version Command 2019 CU 2019 sudo add-apt-repository '$(curl https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)'
2019 GDR 2019 sudo add-apt-repository '$(curl https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019-gdr.list)'
2017 CU 2017 sudo add-apt-repository '$(curl https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2017.list)'
2017 GDR 2017 sudo add-apt-repository '$(curl https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2017-gdr.list)'
- Run apt-get update.
Next steps
After you have configured the correct repository, you can proceed to install or update SQL Server and any related packages from the new repository.
Important
At this point, if you choose to use the RHEL quickstart, remember that you have already configured the target repository. Do not repeat that step in the tutorials. This is especially true if you configure the GDR repository, because the quickstart uses the CU repository.
Important
At this point, if you choose to use the SLES quickstart, remember that you have already configured the target repository. Do not repeat that step in the tutorials. This is especially true if you configure the GDR repository, because the quickstart uses the CU repository.
Important
At this point, if you choose to use the Ubuntu quickstart, remember that you have already configured the target repository. Do not repeat that step in the tutorials. This is especially true if you configure the GDR repository, because the quickstart uses the CU repository.
For more information on how to install SQL Server 2017 on Linux, see Installation guidance for SQL Server on Linux.