This is the 26th day of my participation in Gwen Challenge

The rest of your career is going to be working with Linux, and for those of you who are loyal to.NET, you’re lucky to be getting into Linux right now, because both.net Core and ASP.NET Core are cross-platform. Today I don’t want to try the legendary Linux Sql Server is easy to use.

Install the SQL Server on Centos 7.3

Official documentation: docs.microsoft.com/en-us/sql/l…

OS requirements:

   
Memory 3.25 GB
File System XFS or EXT4 (other file systems, such as BTRFS, are unsupported)
Disk space 6 GB
Processor speed 2 GHz
Processor cores 2 cores
Processor type x64-compatible only
cat  /etc/redhat-release
Copy the code

1. Configure the yum installation source

curl https://packages.microsoft.com/config/rhel/7/mssql-server.repo > /etc/yum.repos.d/mssql-server.repo
Copy the code

2. Install the Mssql Server

yum install -y mssql-server
Copy the code

3. View the version and installation path

rpm -qa | grep mssql
Copy the code

find / -name mssql
Copy the code

4. Configure the Sql Server management account

cd /opt/mssql/bin
Copy the code

./mssql.conf setup (you must stop mSSqL-server to configure)Copy the code

Start the service

systemctl start mssql-server
systemctl enable mssql-server
Copy the code

5. Configure the firewall

Firewall-cmd --add-port='1433/ TCP '--permanent firewall-cmd -- reloadCopy the code

Install the CLI management tool

1. Install the cli tool on the local client

curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
Copy the code
yum install -y mssql-tools
Copy the code

2. Configure SqlCmd environment variables

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash\_profile
Copy the code
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
Copy the code

3. Check the database status

systemctl status mssql-server
Copy the code

If the startup fails, view logs:

journalctl -u mssql-server.service -b
Copy the code

4. Connect to the database

sqlcmd -S localhost -U SA -P ''
Copy the code

5, create database and query

CREATE DATABASE DataTest;
GO
SELECT Name from sys.Databases;
GO
Copy the code

6, general database operations (create table, insert data, query data)

conclusion

Installation steps and official documents about the same, start and installation are very simple.