Green-sell.info

Новые технологии
0 просмотров
Рейтинг статьи
1 звезда2 звезды3 звезды4 звезды5 звезд
Загрузка...

Sql server for linux

Как установить и использовать MS SQL Server в Linux?

В 2016 году Microsoft удивила мир информационных технологий объявлением о своих планах по выпуску MS SQL Server для Linux.

Системным администраторам Linux должны уметь устанавливать, обслуживать и использовать MS SQL Server, особенно учитывая, что пакеты предварительной версии уже доступны для Red Hat Enterprise Linux 7.3+ (включая CentOS 7.3). и также Ubuntu Server 16.04.

Единственное «важное» системное требование для вашей системы — наличие как минимум 2 ГБ ОЗУ.

Установка MS SQL Server в Linux

В этой краткой статье мы расскажем, как установить SQL Server 2019 в выпусках RHEL/CentOS 7.3+ и Ubuntu 16.04.

Установка MS SQL Server на RHEL/CentOS 7.3+

1. Чтобы установить SQL Server в выпусках RHEL/CentOS 7.3+, загрузите файлы конфигурации репозитория Red Hat Microsoft SQL Server 2019 для предварительного просмотра, которые установят пакет mssql-server и mssql-tools с помощью следующих команд curl:

2. Затем установите SQL Server и mssql-tools с пакетом разработчика unixODBC, используя менеджер пакетов yum, как показано ниже:

3. После завершения установки вам будет предложено запустить сценарий конфигурации (/opt/mssql/bin/mssql-conf), чтобы принять условия лицензии, установить пароль для пользователя SA и выбрать свой выпуск ОС:

4. После завершения настройки убедитесь, что служба SQL Server запущена:

5. Откройте порт 1433/tcp на брандмауэре, чтобы внешние клиенты могли обмениваться данными с сервером базы данных:

Если вы используете firewalld:

В противном случае (используя iptables):

Установка MS SQL Server в Ubuntu 16.04

1. Чтобы Ubuntu доверял пакетам из репозиториев MS SQL Server, импортируйте ключи GPG с помощью следующей команды wget:

2. Добавьте репозиторий Microsoft SQL Server Ubuntu для предварительного просмотра SQL Server 2019:

3. Повторно синхронизируйте файлы индекса пакета и обновите основной пакет и дополнительные инструменты:

4. Запустите скрипт конфигурации, как в предыдущем случае:

5. Выберите «Yes», когда вам будет предложено принять условия лицензии для MS SQL Tools:

Тестирование MS SQL Server в Linux

Мы войдем на сервер и создадим базу данных с именем Fabrics. Параметр -P должен сопровождаться паролем, который вы выбрали при предыдущей установке пакета:

Если вы используете Linux, вы можете продолжать использовать командную строку, как показано выше. В противном случае установите SQL Server Management Studio Express, если вы работаете в Windows.

После этого введите IP-адрес сервера базы данных (в данном случае 192.168.0.200) и учетные данные для входа (username=sa, password=YourPasswordHere):

После успешного входа в систему, база данных Fabrics должна появиться слева:

Затем нажмите «Новый запрос», чтобы открыть новое окно запроса, в которое вы вставите содержимое сценария, затем нажмите «Выполнить».

В случае успеха вы увидите, что скрипт создал 5 таблиц:

Чтобы завершить, выполните следующий запрос, чтобы получить первые 5 записей из таблицы клиентов:

Результаты должны быть идентичными результатам на следующем скриншоте:

Поздравляем! Вы успешно установили и протестировали MS SQL Server в Linux!

Итоги

В этой статье мы объяснили, как установить MS SQL Server на RHEL/CentOS и Ubuntu Server.

Из-за обретенной близости Microsoft и Linux системные администраторы Linux должны быть осведомлены о MS SQL Server, если они хотят идти в ногу со временем.

Как всегда, не стесняйтесь использовать форму комментария ниже, чтобы написать нам, если у вас есть какие-либо вопросы. Мы с нетерпением ждем вас!

Спасибо за уделенное время на прочтение статьи!

Если возникли вопросы, задавайте их в комментариях.

Подписывайтесь на обновления нашего блога и оставайтесь в курсе новостей мира инфокоммуникаций!

How to Install and Use MS SQL Server on Linux

by Gabriel Cánepa | Published: November 19, 2016 | Last Updated: October 22, 2019

In the year 2016, Microsoft surprised the IT world with the announcement of their plans to bring MS SQL Server to Linux.

Under Satya Nadella’s leadership, the Redmond giant has made significant progress towards taking advantage of the areas where Linux dominates the industry (such as the technologies that power the cloud). The move to make SQL Server available in Linux is yet another indicative of this approach.

Whatever the company’s motivations behind this initiative, Linux system administrators are likely to need to learn how to install, maintain, and use MS SQL Server – especially considering that the preview version packages are already available for Red Hat Enterprise Linux 7.3+ (includes CentOS 7.3+ as well) and Ubuntu Server 16.04 bits (sorry – no 32-bit version available!).

The only “fancy” system requirement of the preview version is that the system where it is installed must have at least 2 GB of RAM.

Installing MS SQL Server on Linux

In this quickstart article, we will explain how to install SQL Server 2019 preview on RHEL/CentOS 7.3+ releases and Ubuntu 16.04.

Installing MS SQL Server on RHEL/CentOS 7.3+

1. To install SQL Server on RHEL/CentOS 7.3+ releases, download the Microsoft SQL Server 2019 preview Red Hat repository configuration files, which will install the mssql-server package and mssql-tools using the following curl commands.

2. Then install the SQL Server and mssql-tools with the unixODBC developer package using yum package manager, as shown.

Читать еще:  Err empty response что за ошибка

3. When the installation is complete, you will be reminded to run the configuration script (/opt/mssql/bin/mssql-conf) to accept the license terms, set the password for the SA user, and choose your edition.

4. Once the configuration is done, verify that the SQL Server service is running.

5. Open port 1433/tcp on your firewall in order to allow external clients to communicate with the database server:

Installing MS SQL Server on Ubuntu 16.04

1. In order for Ubuntu to trust the packages from the MS SQL Server repositories, import the GPG keys using the following wget command.

2. Add the Microsoft SQL Server Ubuntu repository for SQL Server 2019 preview.

3. Resynchronize the package index files and update the core package and additional tools:

4. Run the configuration script as in the previous case:

SQL Server Setup on Linux

5. Choose “Yes” when prompted to accept the license terms for MS SQL Tools:

Configuring MSSQL Tools on Linux

Testing MS SQL Server on Linux

We will login to the server and create a database named Fabrics. The -P switch must be followed by the password you chose when you installed the package previously:

Create MSSQL Database on Linux

If you’re using Linux, you can continue using the command-line as shown above. Otherwise, install SQL Server Management Studio Express if you’re on Windows.

Once done, enter the IP of the database server (192.168.0.200 in this case) and the login credentials (username=sa, password=YourPasswordHere):

Connect to MSSQL Server

Upon successful login, the Fabrics database should appear at the left-hand side:

Confirm MSSQL Database

Next, click New Query to open a new query window where you’ll insert the contents of the Fabrics script from Codeproject.com, then click Execute.

If successful, you will see the script created 5 tables and the number of records in each:

Create a Sample SQL Database

To wrap up, run the following query to retrieve the first 5 records from the Clients table:

The results should be identical to the output in the following image:

Run MSSQL Database Queries on Linux

Congratulations! You have successfully installed and tested MS SQL Server on Linux!

Summary

In this article, we have explained how to install MS SQL Server on RHEL / CentOS and Ubuntu Server.

Due to the newfound closeness of Microsoft and Linux, Linux system administrators will need to be knowledgeable on MS SQL Server if they want to stay at the top of their game.

By mid-2017, the same SQL Server editions will be offered on Linux as today on Windows: Enterprise, Standard, Web, Express, and Developer. The last two are free but only the Express edition will be licensed for production use (but with resource limits).

As always, feel free to use the comment form below to drop us a note if you have any questions. We look forward to hearing from you!

How to Install MS SQL Server on Linux

This post shows how to install MS SQL Server on Linux (RHEL, CentOS or Ubuntu) and how to connect to it to check it’s working.

At the beginning of 2016, the IT giant Microsoft announced their plans to introduce MS SQL Server on Linux.

Currently, the company is taking full advantage of the spheres where Linux is among the top of the industry, including the technologies that power the cloud. So making SQL Server available in Linux is perfectly in line with the company’s current strategy.

The thing is that the preview version packages are already available for Red Hat Enterprise Linux 7 and Ubuntu Server 16.04 64 bits (unfortunately no 32-bit version is available), so at this point, Linux system administrators might want to start learning how to install, maintain, and use MS SQL Server on Linux.

The only thing to consider before installing MS SQL Server on Linux is that the preview version requires having at least 3.25 GB of RAM and if you have less then the installation will simply issue an error.

How to Install MS SQL Server on Linux

RHEL / CentOS

For starters, you need to add two repositories to software sources list.

1. Paste the following lines into /etc/yum.repos.d/sql-server.repo:

To install the MS SQL Server command-line tools, create /etc/yum.repos.d/msprod.repo with the following script:

2. Once you’ve completed step 1 above, install the packages using yum package manager:

Once the installation is complete, you will be notified to run the configuration script (/opt/mssql/bin/sqlservr-setup), accept the license terms, set the password for the SA user, and start the service. Moreover, there’s an option to enable it to start automatically on boot.

3. Now, open port 1433/tcp on your firewall to allow external clients to communicate with the database server:

Читать еще:  Создание кластера на linux

For those who use firewalld:

For those who use iptables:

Ubuntu

You need to have at least Ubuntu 16.04 or you will face unmet dependencies problems.

1. To make Ubuntu trust the packages from the MS SQL Server repositories, import the GPG keys:

make sure that you have curl installed, you can install it by running

2. Then add the repositories to /etc/apt/sources.list.d/sql-server.list:

3. After that resynchronize the package index files and update the core package and additional tools:

During the process of installation, you will be asked for accepting license terms, answer “Yes” if you have no problems with it

4. After the installation is finished, you need to run the configuration script:

When you are prompted to accept the license terms choose “Yes”.

Then you will be prompted to create the new SQL Server system administrator password. It should be at least 8 characters long and contain uppercase and lowercase letters, numbers and non-alphanumeric characters.

5. Now it’s time to verify that the service is running:

if everything is ok you’ll get something like this:

How to Connect to MS SQL Server on Linux

In order to execute SQL commands, you need to run the sqlcmd client. You can do it using the following command (replace YOUR_PASSWORD with the one you specified during the package installation):

If you got ‘command not found’ error read this. Otherwise, you should see the sqlcmd’s prompt. Let’s execute a simple command that will tell us the SQL Server’s version:

If you see something like this:

then you have successfully installed and connected to you SQL Server on Linux!

Bottom Line

In this ‘how to’ article we have explored Microsoft SQL Server installation process on RHEL / CentOS and Ubuntu Server.

Tip for Linux system administrators: now that Microsoft and Linux are becoming closer you will need to learn more about MS SQL Server to make sure that you are well informed and aware of all the nuances.

It was also announced that by mid-2017 Linux will get the same SQL Server editions as are offered today on Windows: Enterprise, Standard, Web, Express, and Developer. Despite the fact that Express and Developer are free, only the Express edition will be licensed for production use with resource limitations.

We appreciate your feedback! If you have any questions or concerns, or just want to share some info with us, please feel free to comment on this article.

7 thoughts on “ How to Install MS SQL Server on Linux ”

Sorry for my English.
I can not install mssql-server on debian 9. It gives an error: unable to locate package mssql-server
Can you help me?

I’d suggest using Ubuntu, but for Debian, you can try following steps described in https://dba.stackexchange.com/questions/198170/install-sql-server-on-debian

pls chek with msdn doc for ref

It may be because you’re using 32-bit. MS SQL Server is only available for 64-bit versions.

How can we choose the Expression edition before sqlServer installation. Thank in advance.

You will be able to choose an edition when you run
sudo /opt/mssql/bin/mssql-conf setup

Installing and Using mssql-cli on Linux for SQL Server

By: Rajendra Gupta | Updated: 2018-11-27 | Comments | Related: More > Tools
Problem

Microsoft recently released an interactive, cross-platform command line query tool called mssql-cli. My previous tip new interactive command line tool mssqlcli for SQL Server, shows the mssql-cli installation and features on the Windows OS. In this tip, we will see how to install mssql-cli on Linux Ubuntu.

Solution

Microsoft released mssql-cli tool under the OSF (Open Source Foundation) BSD 3 license. The tool is officially available on the below platforms:

  • Windows (x64)
  • Windows (x86)
  • macOS 10.12+
  • Ubuntu 17.04
  • Ubuntu 16.04
  • Ubuntu 14.04
  • Debian 8.7+
  • Debian 9
  • CentOS 7
  • Red Hat Enterprise Linux 7
  • OpenSUSE 42.2+
  • SUSE Enterprise Linux (SLES) 12
  • Fedora 25
  • Fedora 26

Mssql-cli improves the interactive CLI experience for T-SQL and includes support for SQL Server, MySQL, and PostgreSQL. This tool provides great enhancements over SQLCMD due to its features and use. This works great for developers, administrators, and DevOps specialists.

Some of the important features are:

  • Auto-completion
  • T-SQL IntelliSense
  • Syntax highlighting
  • Query history
  • Multi-line queries
  • Formatting for query results, including Vertical Format

Mssql-cli installation on Ubuntu Linux

Mssql-cli installation on Ubuntu depends upon the OS version. In this demo, my operating system version is Ubuntu 16.04.

You can check and verify the OS version using the below methods

Method:1

  • Open the terminal.
  • Enter the lsb_release —a command

Method:2

  • Open «System Settings» from the desktop main menu in Unity.
  • Click on the «Details» icon under «System».

  • See version information

Steps to install mssql-cli on Ubuntu 16.04

Mssql-cli for Linux, is published to package repositories for easy installation (and updates). This is the preferred method. Follow the below steps for the mssql-cli installation.

Читать еще:  Установка linux на hyper v

Step 1: Open terminal and import the public repository GPG keys.

The wget command allows downloading files from the Internet using a Linux operating system such as Ubuntu. It can be used to retrieve files using HTTP, HTTPS and FTP. Wget is non-interactive which gives great flexibility in using it. It can be easily called from scripts, cron jobs, terminals, etc. In this case, we have used it to import the public repository keys.

You can get more information about wget using wget —help.

Step 2: Register the Microsoft Ubuntu repository

We will use curl for this step.

curl is a tool to download or transfer files/data from or to a server using FTP, HTTP, HTTPS, SCP, SFTP, SMB and other supported protocols on Linux or Unix-like system.

Step 3: Update the list of products

apt-get update downloads the package lists from the repositories and updates them to get information on the newest versions of packages and their dependencies. It will do this for all repositories and PPAs.

Step 4: Install mssql-cli

Now use the below command to install mssql-cli tool using apt-get command.

apt-get (advance packaging tools) is the command-line tool for handling packages. It is a rapid, practical, and efficient way to install packages on your system. Dependencies are managed automatically, configuration files are maintained, and upgrades and downgrades are handled carefully to ensure system stability.

This installs the packages, dependencies on Ubuntu.

Steps to install mssql-cli on Ubuntu 17.04

Similarly, we can install mssql-cli on Ubuntu 17.04 with the below steps.

Step 1: Import the public repository GPG keys

Step 2: Register the Microsoft Ubuntu repository

Step 3: Update the list of products

Step 4: Install mssql-cli

Explore mssql-cli on Ubuntu

Once we have installed mssql-cli on Ubuntu, we can check the mssql-cli help documentation using below command:

Some of the important parameters for mssql-cli are:

RootUsers

Guides, tutorials, reviews and news for System Administrators.

How To Install Microsoft SQL Server On Ubuntu Linux

In December 2016 Microsoft made their SQL Server database available in Linux. Here we’ll cover how to install and perform basic setup of MSSQL in the Ubuntu distribution of Linux.

Install MSSQL In Ubuntu 16.10

First we’ll set up the repository file, Microsoft provide a copy of this for Ubuntu here: https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list

We’ll use the wget command to copy this file to the /etc/apt/sources.list.d directory so that we can use it using apt-get. After this we run ‘apt-get update’ in order to sync the package index files with the new source that we’ve just added.

At the time of writing, the 16.10 directory at https://packages.microsoft.com/ubuntu/16.10/mssql-server/ was empty, so I have instead used the 16.04 files here which seems to have worked just fine.

Now that the repository file is in place, installation is as simple as running the following command. At the time of writing the total size of the package and all dependencies was a 747mb download.

Once the installation has completed, we are advised to run the /opt/mssql/bin/sqlservr-setup bash script to complete the setup process.

During my first installation attempt, I got the following error as my virtual machine was only running with 2GB of memory, so be sure that you have enough memory before proceeding.

You’ll be able to proceed once you have adequate memory available.

That’s it, Microsoft SQL Server is now running successfully and listening for traffic on TCP port 1434.

Connecting To MSSQL

In order to actually connect to the server from Linux we need to install the mssql-tools package, which comes from a different repository than the one that we just set up. It can be found here: https://packages.microsoft.com/config/ubuntu/16.04/prod.list

First we’ll download a copy of the prod.list file and place it into the /etc/apt/sources.list.d directory.

We can now proceed with installing the mssql-tools package, as shown below.

Once this is installed we can use the sqlcmd command to interact with the database. To see how to run sqlcmd, simply run it with the -? option for help.

Unfortunately it appears that when you specify the -P option for the password, the password must be provided in the command line with no option of being prompted for it later. Keep in mind that your password will be stored in your bash history running it this way.

In this example we create a test database with a table named websites and a column for domain names. We then insert a domain name and pull it back out with select, confirming both that we are able to connect and that basic SQL queries appear to be working as expected.

Summary

Microsoft’s SQL Server is now available for installation on Linux. Personally I don’t think I’ll ever use this over other alternatives such as MariaDB or PostgreSQL, so hopefully someone somewhere actually finds this information useful!

Ссылка на основную публикацию
ВсеИнструменты
Adblock
detector