SQL Server on Linux
上QQ阅读APP看书,第一时间看更新

SQL Server installation on openSUSE

The following installation procedure is the same for the SUSE Linux Enterprise Server v12 SP2 (SLES), which is officially supported by the Microsoft Corporation. My example is based on openSUSE Leap 42.2.

Another remark is that the installation is based on the SQL Server vNext CTP 1.3 RC1 set of versions, which were actual at the time of writing this book. The installation procedure is command line-based. It means that you will be required to use bash. openSUSE and Kubuntu use the same bash client, Konsole.

If you want to start installation on openSUSE or SLES, you will need minimum 3.25GB of memory to run the SQL Server on Linux. The file system must be XFS or EXT4.

Following are the steps to install SQL Server on Linux on openSUSE:

  1. First of all, you will need to add the mssql-server package to your distribution with the following two commands as shown in the screenshot:
        # sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server.repo
# sudo zypper --gpg-auto-import-keys refresh
Figure 2-7. Result of adding msql-server packages
  1. Now openSUSE knows where to look and find SQL Server binaries. Installation can start with this command:
        # sudo zypper install mssql-server  
Figure 2-8. Result of step two should be like this. Press y or n to start/abort this process
  1. After the installation is over, you can run the mssql-conf setup and follow the procedure. For the sake of security, you need to specify a strong password for the sa account (system administrator). The minimum length is eight characters, a combination of uppercase and lowercase letters, 10 digits and/or non-alphanumeric symbols:
        # sudo /opt/mssql/bin/mssql-conf setup  
Figure 2-9. Setting up sa account and finishing install procedure
  1. Now is the time to check the status of the SQL Server service:
        # systemctl status mssql-server  
Figure 2-10. Information that SQL Server database engine is up and running
  1. In case you need to upgrade the already installed binaries to the new version, you should write following command:
        # sudo zypper update mssql-server          
  1. If you wish to remove the SQL Server from your Linux distribution, write the next bash command:
        # sudo zypper remove mssql-server  

So, SQL Server is successfully installed, and service is up and running. The next step is the installation procedure for mssql-tools repository. It is set of a client (command line) applications to interact with database engine.

The upgrade process will not affect the user and system databases that are located in /opt/mssql/. On the other hand, step 6 will not delete user and system database located in: /var/opt/mssql; you should delete them manually.

SQL Server for Linux in this phase of development has only command line-tools. We are speaking in terms of the Linux platform. The original SQL Server Management Studio, built for Windows, can be used to work with SQL Server on Linux. The only catch is that you need Windows side by side or as a remote client. This book is dealing with Linux, so the focus will be on command line access.

  1. As in the first step of engine installation, we need to add the mssql-tools repository to openSUSE with the following commands:
        # sudo zypper addrepo -fc 
https://packages.microsoft.com/config/sles/12/prod.repo
# sudo zypper --gpg-auto-import-keys refresh
  1. To install mssql-tools with the necessary unixODBC developer package, type the following command:
        # sudo zypper install mssql-tools unixODBC-devel
  1. The following screenshot illustrates the process of installing the tools component. After you say yes, you will be asked to accept (or not) the licence agreement. If you decide to say no, the installation will stop:
Figure 2-11. Starting installation of mssql-tools
  1. In case you want to update only tools to the new version, you run these two commands:
        # sudo zypper refresh
# sudo zypper update mssql-tools
  1. The next step is optional and can save you a lot of time initially while you figure out what is going on. At this moment, bash does not know where the mssql-tools repository is, so you will need to modify your PATH environment variable. The following two commands are referenced for running the sqlcmd and bpc command-line tools:
        # echo 'export PATH="$PATH:/opt/mssql-tools/bin"'>> ~/.bash_profile    
        # echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc    
        # source ~/.bashrc  
  1. Now you need to test your tool. The only way to do this is to try to connect on SQL Server database engine. To start, just type the following:
        # sqlcmd
  1. If you see something like the following screenshot, then you are on the right path:
Figure 2-12. Result of sqlcmd command