In this article, we will learn how to install and configure MS SQL on CentOS 7. Microsoft recently announced their plans to release MS SQL for Linux. Specifically, beta versions are available for Red Hat Enterprise Linux, CentOS, and Ubuntu, but only for 64-bit versions.
Prerequisites
- A machine with at least 4GB RAM and 30GB hard drive space.
- A machine with CentOS 7 installed.
- User with root permissions or root user.
Installing MS SQL Server on CentOS
Since no MS SQL is available in the default CentOS repository, we need to add the details of the MS SQL repository to the local yum repository.
In order to install MS SQL Server using the command line, we need to add the repository to the local yum repository.
# curl https://packages.microsoft.com/config/rhel/7/mssql-server.repo > /etc/yum.repos.d/mssql-server.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 220 100 220 0 0 257 0 --:--:-- --:--:-- --:--:-- 257
After updating the repository, we will run the following command to install the MS-SQL server
# yum update # yum install -y mssql-server … … Resolving Dependencies --> Running transaction check ---> Package mssql-server.x86_64 0:14.0.1.246-6 will be installed --> Processing Dependency: bzip2 for package: mssql-server-14.0.1.246-6.x86_64 --> Processing Dependency: gdb for package: mssql-server-14.0.1.246-6.x86_64 --> Running transaction check ---> Package bzip2.x86_64 0:1.0.6-13.el7 will be installed ---> Package gdb.x86_64 0:7.6.1-80.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: mssql-server x86_64 14.0.1.246-6 packages-microsoft-com-mssql-server 138 M Installing for dependencies: bzip2 x86_64 1.0.6-13.el7 base 52 k gdb x86_64 7.6.1-80.el7 base 2.4 M Transaction Summary ================================================================================ Install 1 Package (+2 Dependent packages) … … +-------------------------------------------------------------------+ | Please run /opt/mssql/bin/sqlservr-setup to complete the setup of | | Microsoft(R) SQL Server(R). | +-------------------------------------------------------------------+ Verifying : mssql-server-14.0.1.246-6.x86_64 1/3 Verifying : gdb-7.6.1-80.el7.x86_64 2/3 Verifying : bzip2-1.0.6-13.el7.x86_64 3/3 Installed: mssql-server.x86_64 0:14.0.1.246-6 Dependency Installed: bzip2.x86_64 0:1.0.6-13.el7 gdb.x86_64 0:7.6.1-80.el7 Complete!
Configure MS SQL SA account
Once the installation is complete, we will run sqlservr- setup script to set the SA password; we need to provide a strong password for the SA account (at least 8 characters, lowercase and uppercase letters and numbers from 1 to 10 or any non-alphanumeric characters)
# sudo /opt/mssql/bin/sqlservr-setup Microsoft(R) SQL Server(R) Setup You can abort setup at any time by pressing Ctrl-C. Start this program with the --help option for information about running it in unattended mode. Please enter a password for the system administrator (SA) account: Please confirm the password for the system administrator (SA) account: Setting a password for the system administrator (SA) account Do you wish to start the SQL Server service now? [y/n]: Y Do you wish to enable SQL Server to start on boot? [y/n]: y Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service. Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server-telemetry.service to /usr/lib/systemd/system/mssql-server-telemetry.service. Setup completed successfully.
After configuration is complete , we will restart the MS SQL service and use the following command to view the status of the service:
Restart the service
# systemctl start mssql-server
View the status of the service
# systemctl status mssql-server mssql-server.service - Microsoft(R) SQL Server(R) Database EngineLoaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2016-12-02 15:52:33 IST; 5min ago Main PID: 2299 (sqlservr) CGroup: /system.slice/mssql-server.service ├─2299 /opt/mssql/bin/sqlservr └─2307 /opt/mssql/bin/sqlservr Dec 02 15:52:37 localhost.localdomain sqlservr[2299]: 2016-12-02 10:22:37.31 spid17s.... Dec 02 15:52:37 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/mssql-ser...' Dec 02 15:52:37 localhost.localdomain sqlservr[2299]: 2016-12-02 10:22:37.53 spid6s .... .. .. Dec 02 15:57:40 localhost.localdomain sqlservr[2299]: 2016-12-02 10:27:40.21 spid51 ...' Dec 02 15:57:43 localhost.localdomain systemd[1]: Started Microsoft(R) SQL Server(R)....Hint: Some lines were eclipsed, use -l to show in full.
Open the MS SQL firewall
We need to open the firewall settings so that MS SQL can be accessed. The following is the command to open the firewall
# sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent # sudo firewall-cmd –reload
Install MS SQL tools
We need to download the Microsoft warehouse.
# curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 193 100 193 0 0 213 0 --:--:-- --:--:-- --:--:-- 213
Once the repository is installed on the local machine, we can install MS SQL tools using the following command:
# yum install mssql-tools Loaded plugins: fastestmirror packages-microsoft-com-prod | 2.9 kB 00:00:00 packages-microsoft-com-prod/primary_db | 4.6 kB 00:00:00 Loading mirror speeds from cached hostfile * base: mirrors.digipower.vn * extras: mirror.digistar.vn * updates: mirror.digistar.vn Resolving Dependencies ======================================================================================== Package Arch Version Repository Size ======================================================================================== Installing: mssql-tools x86_64 14.0.1.246-1 packages-microsoft-com-prod 249 k Installing for dependencies: libtool-ltdl x86_64 2.4.2-21.el7_2 updates 49 k msodbcsql x86_64 13.0.1.0-1 packages-microsoft-com-prod 3.8 M unixODBC-utf16 x86_64 2.3.1-1 packages-microsoft-com-prod 329 k Transaction Summary ======================================================================================== Install 1 Package (+3 Dependent packages) Total download size: 4.5 M Installed size: 4.5 M Is this ok [y/d/N]: ^CN Exiting on user command Your transaction was saved, rerun it with: yum load-transaction /tmp/yum_save_tx.2016-12-02.17-18.RpEVqg.yumtx Do you accept the license terms? (Enter YES or NO)YES Installing : msodbcsql-13.0.1.0-1.x86_64 3/4 The license terms for this product can be downloaded from http://go.microsoft.com/fwlink/?LinkId=746949 and found in /usr/share/doc/mssql-tools/LICENSE.txt . By entering 'YES,' you indicate that you accept the license terms. Do you accept the license terms? (Enter YES or NO)YES Dependency Installed: libtool-ltdl.x86_64 0:2.4.2-21.el7_2 msodbcsql.x86_64 0:13.0.1.0-1 unixODBC-utf16.x86_64 0:2.3.1-1 Complete!
Connect to SQL Server on Linux
on the computer After installing the tool, we will test the following commands and general syntax to connect to MS SQL Server.
Syntax
# sqlcmd –S IP-ADDRESS –U SA –P ‘<YOUR SYSTEM PASSWORD’ # sqlcmd sqlcmd -S localhost -U SA -P Test@1234 1>CREATE DATABASE TEST1; 2>GO; 3>quit
In the above article, we learned – How to install MS SQL Server, MS SQL command line tool to connect to the server. We also learned – How to change or set SA account password for MS SQL.
The above is the detailed content of How to install and configure MS SQL (beta) on CentOS 7. For more information, please follow other related articles on the PHP Chinese website!

Stored procedures are precompiled SQL statements in MySQL for improving performance and simplifying complex operations. 1. Improve performance: After the first compilation, subsequent calls do not need to be recompiled. 2. Improve security: Restrict data table access through permission control. 3. Simplify complex operations: combine multiple SQL statements to simplify application layer logic.

The working principle of MySQL query cache is to store the results of SELECT query, and when the same query is executed again, the cached results are directly returned. 1) Query cache improves database reading performance and finds cached results through hash values. 2) Simple configuration, set query_cache_type and query_cache_size in MySQL configuration file. 3) Use the SQL_NO_CACHE keyword to disable the cache of specific queries. 4) In high-frequency update environments, query cache may cause performance bottlenecks and needs to be optimized for use through monitoring and adjustment of parameters.

The reasons why MySQL is widely used in various projects include: 1. High performance and scalability, supporting multiple storage engines; 2. Easy to use and maintain, simple configuration and rich tools; 3. Rich ecosystem, attracting a large number of community and third-party tool support; 4. Cross-platform support, suitable for multiple operating systems.

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download
The most popular open source editor

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version
SublimeText3 Linux latest version

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
