Ubuntu Install SQL Server on Linux - SQL Server Microsoft Learn

Telechargé par sofiene Dach
Quickstart: Install SQL Server and create
a database on Ubuntu
Article • 12/20/2023
Applies to: SQL Server - Linux
In this quickstart, you install SQL Server 2022 (16.x) on Ubuntu 20.04 or 22.04. Then you
can connect with sqlcmd to create your first database and run queries.
For more information on supported platforms, see Release notes for SQL Server 2022
(16.x) on Linux.
If you choose to have a preinstalled SQL Server VM on Ubuntu ready to run your
production-based workload, then follow the best practices for creating the SQL Server
VM.
You can create your VM based on the following Azure Marketplace image: Ubuntu
20.04 .
When you use this image, you avoid the installation step, and can directly configure the
instance by providing the SKU and the sa password needed to get started with SQL
Server. SQL Server Azure VMs deployed on Ubuntu Pro using the above Marketplace
images, are fully supported by both Microsoft and Canonical.
You can configure SQL Server on Linux with mssql-conf, using the following command:
Bash
Tip
This tutorial requires user input and an internet connection. If you're interested in
the unattended or offline installation procedures, see Installation guidance for
SQL Server on Linux.
Azure Marketplace image
sudo /opt/mssql/bin/mssql-conf setup
Prerequisites
You must have an Ubuntu 20.04 machine with at least 2 GB of memory.
To install Ubuntu 20.04 on your own machine, go to
https://releases.ubuntu.com/20.04/ . You can also create Ubuntu virtual machines in
Azure. See Create and Manage Linux VMs with the Azure CLI.
If you've previously installed a Community Technology Preview (CTP) or Release
Candidate (RC) of SQL Server, you must first remove the old repository before following
these steps. For more information, see Configure repositories for installing and
upgrading SQL Server on Linux.
The Windows Subsystem for Linux isn't supported as an installation target for SQL
Server.
For other system requirements, see System requirements for SQL Server on Linux.
To configure SQL Server on Ubuntu, run the following commands in a terminal to install
the mssql-server package.
1. Import the public repository GPG keys:
Bash
2. Register the SQL Server Ubuntu repository:
Bash
Install SQL Server
Ubuntu 20.04
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee
/etc/apt/trusted.gpg.d/microsoft.asc
sudo add-apt-repository "$(wget -qO-
https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-
2022.list)"
Tip
If you want to install a different version of SQL Server, see the SQL Server
2017 (14.x) or SQL Server 2019 (15.x) versions of this article.
3. Run the following commands to install SQL Server:
Bash
4. After the package installation finishes, run mssql-conf setup and follow the
prompts to set the SA password and choose your edition. As a reminder, the
following SQL Server editions are freely licensed: Evaluation, Developer, and
Express.
Bash
Remember to specify a strong password for the SA account. You need a
minimum length 8 characters, including uppercase and lowercase letters,
base-10 digits and/or non-alphanumeric symbols.
5. Once the configuration is done, verify that the service is running:
Bash
6. 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!
When you connect to your SQL Server instance using the sa account for the first time
after installation, it's important for you to follow these steps, and then immediately
disable the sa login as a security best practice.
1. Create a new login, and make it a member of the sysadmin server role.
Depending on whether you have a container or non-container deployment,
enable Windows authentication, and create a new Windows-based login and
add it to the sysadmin server role.
sudo apt-get update
sudo apt-get install -y mssql-server
sudo /opt/mssql/bin/mssql-conf setup
systemctl status mssql-server --no-pager
Disable the sa account as a best practice
Tutorial: Use adutil to configure Active Directory authentication with SQL
Server on Linux
Tutorial: Configure Active Directory authentication with SQL Server on
Linux containers
Otherwise, create a login using SQL Server authentication, and add it to the
sysadmin server role.
2. Connect to the SQL Server instance using the new login you created.
3. Disable the sa account, as recommended for security best practice.
To create a database, you need to connect with a tool that can run Transact-SQL
statements on SQL Server. The following steps install the SQL Server command-line
tools: sqlcmd utility and bcp utility.
Use the following steps to install the mssql-tools18 on Ubuntu.
1. Import the public repository GPG keys.
Bash
2. Register the Microsoft Ubuntu repository.
For Ubuntu 22.04, use the following command:
Bash
For Ubuntu 20.04, use the following command:
Install the SQL Server command-line tools
Note
Ubuntu 18.04 is supported starting with SQL Server 2019 (15.x) CU 3.
Ubuntu 20.04 is supported starting with SQL Server 2019 (15.x) CU 10.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee
/etc/apt/trusted.gpg.d/microsoft.asc
curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list
| sudo tee /etc/apt/sources.list.d/mssql-release.list
Bash
For Ubuntu 18.04, use the following command:
Bash
For Ubuntu 16.04, use the following command:
Bash
3. Update the sources list and run the installation command with the unixODBC
developer package.
Bash
4. Optional: Add /opt/mssql-tools18/bin/ to your PATH environment variable in a
bash shell.
To make sqlcmd and bcp accessible from the bash shell for login sessions, modify
your PATH in the ~/.bash_profile file with the following command:
Bash
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list
| sudo tee /etc/apt/sources.list.d/mssql-release.list
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list
| sudo tee /etc/apt/sources.list.d/mssql-release.list
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list
| sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo apt-get install mssql-tools18 unixodbc-dev
Note
To update to the latest version of mssql-tools, run the following commands:
Bash
sudo apt-get update
sudo apt-get install mssql-tools18
1 / 10 100%

Ubuntu Install SQL Server on Linux - SQL Server Microsoft Learn

Telechargé par sofiene Dach
La catégorie de ce document est-elle correcte?
Merci pour votre participation!

Faire une suggestion

Avez-vous trouvé des erreurs dans linterface ou les textes ? Ou savez-vous comment améliorer linterface utilisateur de StudyLib ? Nhésitez pas à envoyer vos suggestions. Cest très important pour nous !